连接使用VBA从单元中减去的细胞
我希望将按钮连接到 i3 和 l3 中的单元格。因此,每当单元格 i3 中的数字与 l3 中的数字相加或相减时,总是从 500 美元开始减去。因此,如果 40 在单元格 i3 中,则单元格 l3 应读取为 460。如果 60 在单元格 i3 中,则单元格 l3 应读取 440。我已在下面添加了代码。我下面的代码现在只是从单元格 i3 中添加和减去。
Sub Lower()
Range("i3").Value = Range("i3").Value - 1
End Sub
Sub Higher()
Range("i3").Value = Range("i3").Value + 1
End Sub
I am looking to connect the buttons to the cells in i3 and cell l3. So that whenever the number iin cell i3 is added or subtracted to the number in l3 is always subtracted from starting at 500 dollars. So if 40 is in cell i3 cell l3 should read for 460. If 60 is in cell i3 then cell l3 should read 440. I have added my code below. My code below right now just adds and subtracts from cell i3.
Sub Lower()
Range("i3").Value = Range("i3").Value - 1
End Sub
Sub Higher()
Range("i3").Value = Range("i3").Value + 1
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用i3的设置总额
是最简单的方法是使L3 = 500 -i3的公式。
如果您想在VBA中进行操作,请尝试以下操作:
它使用更改触发Cell L3的计算。
将子与
标准命令按钮的命令按钮相关联,在设计模式下,右键单击每个按钮,然后单击
分配宏
。然后从列表中选择子。对于ActiveX按钮,在设计模式下,右键单击按钮,然后单击
查看代码
(或只需双击命令按钮)。在添加的单击事件子中,将关联的代码移至新创建的代码。示例:
注意:< / strong>子名称将 /必须匹配命令按钮的(名称)而不是字幕(显示的文本)。默认情况下,第一个命令按钮将是
commandbutton1_click()
。Setup Total Money with I3
The easiest way would be to have the formula of L3 = 500 - I3.
If you wish to do it in vba try this:
It uses the change event of the worksheet to trigger a calculation of cell L3.
Associate Sub with Command Button
For standard command buttons, in design mode, right click each button and then click
Assign Macro
. Then select the sub from the list.For ActiveX buttons, in design mode, right click the button and click
View Code
(or just double click the command button). In the added click event sub, move the associated code to the newly created one.Example:
NOTE: The sub's name will / must match the command button's (name) not caption (displayed text). By default the first command button would be
CommandButton1_Click()
.