Assigning a recorded macro to a Command Button!

phillipsjr

New Member
Joined
Jul 21, 2003
Messages
10
Hi Guys and girls, please help me.
I’m having trouble assigning a pre-recorded macro to a command button. After creating the command button, I right click on the button as suggested but I can’t se an “Assign Macro” option in the short menu. Is there any other way of assigning a pre-recorded macro to a command button or am I doing something wrong?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Phillip,

Welcome to the Board!

If you're using a button created from the Forms toolbar, you can assign a macro by right-clicking.

If you're using a button created from the Control Toolbox, you need to call your macro from the button's click event. In Design mode, double-click the button and you'll get this:

Code:
Private Sub CommandButton1_Click()
  Application.Run "Your Macro"
  ' Or place your macro code here
End Sub

Hope that helps,

Smitty
 
Upvote 0
I was searching for this one for a while..I was trying to run my command button by pasting the code, but it was not working.But Application.run worked for me!Thanks a lot Smitty !
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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