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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
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...)
 

Cath

Board Regular
Joined
Aug 10, 2005
Messages
156
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,437
Messages
5,831,620
Members
430,077
Latest member
CoulterM

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
Top