Copying click Command Buttons

Simmer77

New Member
Joined
Oct 9, 2017
Messages
1
Hi folks,
I used the formula below to simply click the command button to add 1 to the number

Private Sub CommandButton1_Click()
Dim x As Integer
x = Range("A1").Value
Range("A1").Value = x + 1
End Sub


The application is... I am counting visitors between a 2 hour time period during the day in a retail store. So, I need approx 5 buttons. I copied the original button and then changed the code to point to the proper cell, however, every one of the buttons maintains the cell address of the latest button for which I changed the cell address?? It seems I am unable to have multiple buttons performing the same task, but for adjoining cells. Is there a way around that? (I will also be replicating the sheet for each week)

I am not an excel WIZARD but thought I had this one figured out. Thank you if you are able to help

Greg
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi & welcome to MrExcel.
Did you change the name of the sub for each button. ie
Code:
[FONT=Courier]CommandButton1_Click[/FONT]
to
Code:
[FONT=Courier]CommandButton[COLOR=#ff0000]2[/COLOR]_Click[/FONT]
etc
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top