![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 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! |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
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.
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
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... |
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Posts: 17
|
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 |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
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 |
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Posts: 17
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|