Button that will increment by 1

M

Mr-Re Man

I am in the process of trying to create a spreadsheet that will have 5 buttons.
I want to position the button in cell B2, then when pressed it will
increment cell C2 by 1.

Then I need to repeat this 4 times so I'll have buttons and results in cells
B3 & C3, B4 & C4 etc.

I used this code from another thread, Selection.Value = Selection.Value + 1,
but it didn't work for 2 buttons, it incremented the same value whichever
button was pressed.
 
M

Mike H

Hi,

View|Toolbars|Forms and click the 'Button Icon' and draw a button over B2 by
dragging. As soon as you stop dragging in the popup window click 'New' and
enter this code

Sub Button1_Click()
Range("C2").Value = Range("C2").Value + 1
End Sub

It will already have the first and last lines. Repeat this process for your
other buttons modifying the range C2 as appropriate.

Mike
 
M

Mr-Re Man

Awesome, thank you so much

Mike H said:
Hi,

View|Toolbars|Forms and click the 'Button Icon' and draw a button over B2 by
dragging. As soon as you stop dragging in the popup window click 'New' and
enter this code

Sub Button1_Click()
Range("C2").Value = Range("C2").Value + 1
End Sub

It will already have the first and last lines. Repeat this process for your
other buttons modifying the range C2 as appropriate.

Mike
 

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