Assign Macro to Command Button in Excel 2002

DJM1216

Board Regular
Joined
Apr 15, 2002
Messages
102
Hi, I'm trying to assign a macro to a command box in Excel 2002.

When I clicked on "help" within excel the directions don't help me. For example, the directions tell me to right click a sizing handle, and select "Assign Macro" from the shortcut list.

When I right click a sizing handle, my only choices are:

Cut
Copy
Paste
Properties
View Code
Command Button Object
Grouping
Order
Format Control

I have the macro recorded, I just want to know how to assign the macro to the button so that once it's pushed, the macro runs.

Thanks in advance for any help you can provide.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,328
Office Version
  1. 365
Platform
  1. Windows
Which toolbar did you use to create the command button?

It sounds to me that you used the Control Tololbox rather than the Forms one.

If that's the case you don't actually assign a macro.

Select View Code when you right click and the VBA editor should open and you will see something like this:

Code:
Private Sub CommandButton1_Click()

End Sub

To use your macro either copy and paste the code from it in here or call it from here.
 

DJM1216

Board Regular
Joined
Apr 15, 2002
Messages
102
That did the trick, thank you!

I did use the control toolbox.

Is there an easier button to format? You mentioned "Forms".

Thanks again.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,328
Office Version
  1. 365
Platform
  1. Windows
Well the two buttons have there differences.

As to fomatting a button from the Forms toolbar is far more limited than one from the Control Toolbox.

You can change the background and font colour and various other properties.
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,609
Messages
5,765,408
Members
425,284
Latest member
fishymuffin

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