assign macro?

lukemedway

New Member
Joined
May 6, 2002
Messages
17
Can someone please tell me how to assign a macro to a command button in Office XP.

I have looked in the help files which all refer to assigning macros to buttons in the "toolbar" well i dont want that, i want to assign it to a command button... I have been trying to do this for 2 days and i cant see the assign button anywhere

Please help its frustrating me!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Maybe your refering to some other command button then one from forms tool bar that has been dropped onto the sheet. For these command buttons you just right click on button and then left click on "assign macro" from the drop down menu.
 
Upvote 0
First off, I am assuming you want to assign to a command button you added to a worksheet.

If the button was placed on the sheet from the Forms toolbar, it should have asked you to assign a macro as soon as you put it there.

If the button was placed on the sheet from the controls toolbar, you just need to double-click it and it will take you to the VB editor. The sub will be something like:

Private Sub CommandButton1_Click()

End Sub

Cut and paste the code from your macro there.

P.S. Also assuming you are using Excel 97 or later...
 
Upvote 0
LOL, this is what im reading all the time but when i right click on the button there isnt an assign macro option...

All there is, is this:

Cut
Copy
Paste
Properties
View Code
commandButton Object
Grouping
Order
Format control
 
Upvote 0
You definately have an ActiveX command button. You should be able to either double-click on it or select View Code. This will take you to the VB Editor. Paste your macro inside the Click Event.

Private Sub CommandButton1_Click()

Your code here...

End Sub

K
 
Upvote 0
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA *BREATH* HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA

OMG, I WAS USING THE BUTTON FROM THE CONTROL BOX DOH!

HOW COULD I HAVE MISSED THAT *FEELS EXTREMLY SILLY AND HIDES UNDER A ROCK*

THANKS FOR THE HELP LADS :wink:
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

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