attaching a macro to a button in excel 97

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
everything i see online says to right click on a created button and attach the macro. i get no such option. i've done this many times before but cannot work out why its not happening today!

only options i get outside the normal ones is CommandButton Object


HELP! :confused:
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
What are u trying ?
Addition button to sheet or New Tool Bar or to Userform ???
 
Upvote 0
i've created a standard button right clicking on it in design mode (i.e. will not run macro on click) and i'm not getting an attach macro option - i can get to the macro code via vb editor shall i just copy the macro entirly into it?

will that work?
 
Upvote 0
Rightclick the button -> View Code -> This will take u to VBA editor->

Private Sub CommandButton1_Click()

End Sub

Paste ur code here -> save close -> Ur macro will get trigger on "Click" event ......

Check out the second box in VBA editor to see more "Events" on which u can trigger the macro !!!

Hope this is what u r looking for !!!!
 
Upvote 0
Hi

You're probably thinking of a Forms button rather than one from the Controls toolbox. You can go View>Toolbars> check Forms and then use the button off of here. If you right click on this, you should have the option to assign macro.
 
Upvote 0
hi i've tried that and am getting a select method of range class failed error where the macro is ok to run on its own i get this message via the button
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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