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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

hsk

Well-known Member
Joined
Oct 19, 2006
Messages
567
What are u trying ?
Addition button to sheet or New Tool Bar or to Userform ???
 

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
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?
 

hsk

Well-known Member
Joined
Oct 19, 2006
Messages
567
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 !!!!
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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.
 

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
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
 

Forum statistics

Threads
1,181,102
Messages
5,928,062
Members
436,586
Latest member
latintxn

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