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
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,758
Messages
5,574,071
Members
412,566
Latest member
TexasTony
Top