Call A Macro From A ControlButton

  • Thread starter Thread starter Minitman
  • Start date Start date
M

Minitman

Greeting,

I put a control button from the "Control Toolbox" on my worksheet. I
have a macro that i would like to have this button call up. I tried

Call Macro1

which worked when accessed from a UserForm, but not from the sheet.

Any suggestions?

TIA

-Minitman
 
Did you put it in the Commandbutton1_Click event procedure?

Is Macro1 a public sub on a standard code module?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hey Bob,

Yes, I put it in the CommandButton1_Click event procedure in the sheet
that the CommandButton is on.

Not sure on this one, It is in Module2. I can call it up from a
UserForm CommandButton and it works there, but not on the worksheet.

I am using this to call the macro:

Private Sub CommandButton1_Click()
Call Macro1
End Sub

-Minitman
 
That all seems in order then.

If you can call it from a Userform, it should also work from the Worksheet,
they are both class modules.

Very odd, no other thoughts at the moment I am afraid.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hey Bob,

I found the problem! I was using the wrong command for the sheet.
The correct command is as follows:

Application.Run "'Macro1"

and not:

Call Macro1

Which does run in the UserForm.

Micro$oft strikes again. <G>

-Minitman
 
Why, are you running it from a different workbook?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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