将VBA功能应用于按钮直接上方的单元格
在我的VBA代码中,目标是在按钮上方的单元格中添加500个。现在,所讨论的按钮在“ C7”单元格中。我希望每次按下按钮时,它正上方的单元格是“ B7”。我想在整个工作表中复制按钮以添加单元格。因此,代码必须像Cell.above +500之类的东西。我在下面添加了当前的代码。
Range("b7").Value = Range("b7").Value + 500
In my vba code the goal is to add 500 to the cell above the button. Right now the button in question is in cell "c7". I want the cell directly above it which is cell be "b7" to add 500 every time the button is pressed. I would like to copy the button to add for cells throughout the worksheet. So the code has to be something like cell.above +500 or something like that. I added my current code below.
Range("b7").Value = Range("b7").Value + 500
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是表单按钮,则是这样:
您可以添加
iif
以查看它是否为空白并在500
(或其他)中“初始化”它,如果是你渴望。确保您正在查看正确的表格 - 这是在
Sheet1
对象代码模块中添加的。否则,您可能需要指定表格。
另外,当您复制它们时,您需要重命名它们(默认情况下,它们以相同的名称复制)。
If you're using a form button, it's like this:
You can add the
IIF
to see if it's blank and "initialize" it at500
(or whatever) if that's you're desire.Make sure you're looking at the right sheet - this was added in the
Sheet1
object code module.Otherwise, you may need to specify a sheet.
Also, when you're copying them, you need to rename them (by default they are copied with the same name).