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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Where is the code for VOUCHER_DriverExpenses located?
 
Upvote 0
Duh,

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

It should be
Code:
Private Sub CommandButton1_Click()

Smitty
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,517
Members
448,968
Latest member
Ajax40

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