Assign MAcro to command button

  • Thread starter Thread starter T De Villiers
  • Start date Start date
T

T De Villiers

Hi, I have a macro in my workbook called REV,

I need to assign this macro to a commnd button.
The following is what I have so far, am clearly missing something
cos' its not quite working.

Many Thanks


Private Sub CommandButton1_Click()
REV
End Su
 
Many ways to do it but the easiest is.....
From the toolbar menu select the forms toolbar
then pick command button to draw.
If should give you option to pick macro and assign if not right click
 
There are two kinds of command buttons. i am assuming that you grabbed your
button from the Control Toolbox and placed it on a sheet. When you do this
your sheet will be in design mode. If you right click on that button you can
change the properties and view the code. Select View code. It will take you
to the VBE and should have a stub entered for you similar to the code that
you posted... In that code add the line...

msgbox "tada"

and go back to your sheet. Exit design mode by clicking the Triangle icon on
the control toolbox. Now when you click the button your message box should
show up. Swap out the message box for REV and you should be off to the
races... If something crashes or does not work along the way post back...
 
How do you call a macro with arguments in a Command Button on Sheet1
which references Cell A1 value "Supplies".
'Target' would pass A1 value

Example
Public Sub Cmd_Services_Click(ByVal Target As CommandButton)
'run code in Sheet1
ABC(Target)
End Sub

In the properties window for command button, Name = Cmd_Services
Should it be Name - Cmd_Services(A1) ?
Cmd_Services(Sheet1!A1) ?

I'm Frustrated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top