Command Button Macro Link

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
I am having trouble with Assigning a Macro to a Command Button. Being new I think there may just be something simple that I am not doing. I have the Command Button in the appropriate spot on my sheets and I have the right macro created already but I can't seem to link the two. My Macro name is: VOUCHER_DriverExpenses.

The code is:

Sub CommandButton1_Click()
Call VOUCHER_DriverExpenses
End Sub

When I attach the above code to the control button and hit the button I get an error message.

I can run the macro just fine on it's own.

Any help would be appreciated.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Where is the code for VOUCHER_DriverExpenses located?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Duh,

I completely overlooked the fact that you're missing "Private" in the Sub line.

It should be
Code:
Private Sub CommandButton1_Click()

Smitty
 

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46

ADVERTISEMENT

I am sorry I have tried to do it with the Private Sub but to the same results (ie. Error Mesage). The macro is stored in the PERSONAL.XLS file.
 

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
I am sorry I have tried to do it with the Private Sub but to the same results (ie. Error Mesage). The macro is stored in the PERSONAL.XLS file.
 

Forum statistics

Threads
1,141,680
Messages
5,707,788
Members
421,527
Latest member
Tamiwsw

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