Command Button Function

B

bob

I am setting up a simple interface in which I want to click Button1 and then
Button2 to increase the value in cell E2 by 1. I want the value to increase
by 1 each time I click these two button in sequence.

Can anyone provide the code to accomplish this?

thanks,
Bob
 
G

Gary''s Student

Make two buttons using the Forms toolbar. Then enter:

Dim arm_it As Boolean

Sub but1()
arm_it = True
End Sub

Sub but2()
If arm_it Then
arm_it = False
Range("E2").Value = Range("E2") + 1
End If
End Sub


in a standard module and assign the first button to but1, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top