Using command button to run a macro

Lauralou

New Member
Joined
Oct 11, 2004
Messages
32
Hi there

I want to put a button in my worksheet that will run a really simple macro that I've recorded. Can anyone help me with how I go about doing that. I've found the design toolbar and I can put a button on the sheet but I can't work out how to connect it to a macro.

Thanks

LL
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Right Click on the button and go to View Code - This will open the VB Window and give you something like:

Code:
Private Sub CommandButton1_Click()

End Sub

Paste your code in the middle or call it from another module

If you can't right click on the button you need to enter design mode (Green Set Square...)
 
Upvote 0
If you right click on the button you will get a view code option. If you go into this, this is where your macro should be. If you've already done a macro then you could just copy and paste it into here.

Cath
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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