Run a macro using a command button

  • Thread starter Thread starter Tdahlman
  • Start date Start date
T

Tdahlman

I have created a macro using the Macro Recorder.
I have a command button and I want to run the macro (which is names
DATASORT) when I click the button.

Please advise how to make this work.

Thanks in advance,
Travis
 
This will depend on the type of command button you created. Right-click
your command button. If there is an option to "Assign Macro", then that's
how you do it. If not, then click "View Code"

Enter this text.

Call <your macro name, no brackets>


HTH,
Paul
 
Go to "View" & "Toolbars". Show the forms toolbar.

Click the "button" button. (I know it doesn't make sense, but if you hover
your cursor over, it will say "button")

You'll get a cursor where you can drag & drop a button.

Once you have the button, right click & choose "assign macro".
 
hi
on the toolbox toolbar, chick design mode. the icon looks like a protractor
with ruller and pencil. in design mode right click the button. from the
popup, click view code. add this......
Private Sub CommandButton1_Click()
call DATASORT
End Sub
close the vb window.
if you need to relocate or resize the button, do so now.
click design mode icon again to exit design mode.
done. button is live.

Regards
FSt1
 

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