I created a Command Button on one page of a spreadsheet and managed to give it a Title so how do I link a macro that I have already created to this button ?
I an using Excel 2010
If you wanted to know the answer to your original question, tell us whether the Command Button was from the Form Controls or the ActiveX Controls section.
Then the process would be.
- On the Developer ribbon tab enter 'Design Mode' via the button of that name.
- Right click the Command Button and choose "View Code".
- That should take you to the worksheet's module in the vba window & present you with code like
Code:
Private Sub CommandButton1_Click()
End Sub
- Just enter the name of your macro between those lines. So if your macro was called Do_Stuff it would become
Code:
Private Sub CommandButton1_Click()
Do_Stuff
End Sub
- Back at the worksheet, exit Design Mode by clicking that ribbon button again.
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.