使用Excel中的宏编辑另一个表中的单元格值?
我有一个 Excel 项目,其中包含 3 个工作表,即“不健康食品”、“健康食品”和“膳食”。
这两个食品表包含食品列表及其脂肪、蛋白质和碳水化合物含量。利用这些数据,还可以计算出每 100 克的卡路里含量。这些食品分为 3 个小标题:食品、零食和饮料。我想创建一个宏,该宏将使用每个桌子上每个食物旁边的“添加到餐食”按钮启动,该按钮会将行的内容复制到“餐食”类中的第一个可用行。
这有可能做到吗?如果是这样,怎么办?
I have an Excel project which contains 3 worksheets, namely "Unhealthy Foods" "Healthy Foods" and "Meal"
The two food tables contain a list of foods along with their their fat, protein and carbohydrate content. Using that data, their calories per 100 grams are also calculated. These foods are divided into 3 sub-headings: Foods, snacks and drinks. I want to create a macro which will be launched using an "Add to Meal" button next to each food item on each table which will copy the row's content to the first available row in the "Meal" class.
Is it possible for this to be done? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(在我看来)使用按钮引用工作表上的单元格的问题是按钮是工作表上的对象,这使得获取它们在列/行方面的位置非常棘手。
如果您想使用按钮,这里是强力方法。假设在
Healthy Foods
中您有以下内容:以下代码会将详细信息复制到
Meal
中的下一个可用行(注意 - 我假设 Meal 与上面所示的表格格式相同)对于士力架,您需要为 Apple ie 添加类似的代码,
如果这对您有用,很好,但可能需要一些设置,并且是一种蛮力方法。
The issue (in my opinion) with using buttons to refer to cells on a worksheet is that buttons are objects on the worksheet which makes getting their position in terms of column / row quite tricky.
Here is the brute force approach if you want to use buttons. Suppose in
Healthy Foods
you have the folllowing:The following code will copy the details to next available row in
Meal
(NB - I assume Meal is same table format as shown above)For Snickers you would need to add simialr code for Apple i.e.
If this works for you, fine, but it may take some setting up and is a brute force approach.