Coding Multiple Command Buttons

Bfiftytwo

New Member
Joined
Mar 21, 2013
Messages
1
Hello,

I am creating an inventory stationary stock list at the school I work at. It will be accessible to 5 members of staff who use the stationary cupboard.

When a member of staff takes a ream of paper they can click the paper button under their name, which will indicate they have taken one ream of paper and subtract it off the paper stock.

There is in excess of 200 buttons, do I need to code each one individually or is there a way to copy the code and it automatically change the button name and cell numbers?

Example of code

Code:
Private Sub MCR1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Sheets("sheet1").Range("d4").Value = Sheets("sheet1").Range("d4").Value + 1
End Sub

next button

Code:
Private Sub MCR2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Sheets("sheet1").Range("d5").Value = Sheets("sheet1").Range("d5").Value + 1
End Sub
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,207,095
Messages
6,076,552
Members
446,213
Latest member
bettigb

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