Assign Macro function

G

gus

Hi!
I've inserted a command button on my spreadsheet and I want to assing a
macro to it, however when I right-click the object, the option "Assign
Macro" is not available. How do I solve that?

Thanks,
Gus
 
A

Andy Brown

Hi Gus.
I've inserted a command button on my spreadsheet and I want to assing a
macro to it, however when I right-click the object, the option "Assign
Macro" is not available.

Possibly it's a command button of the Control ToolBox variety. Do you have a
"View Code" rightclick option?

HTH,
Andy
 
G

gus

Hi Andy!
Yep. I do.
But I don't know how to assign a macro this way. Any clue?

Tks,
Gus
 
A

Andy Brown

But I don't know how to assign a macro this way. Any clue?

Select the View Code option, you'll be transported to the Visual Basic
Editor. Excel will give you a head start with something like

Private Sub CommandButton1_Click()

End Sub

, whatever you want the button to do (e.g. MsgBox "Hi!") goes between the
lines. Tho' when you switch back to Excel proper, make sure you Exit Design
Mode (first icon/button on the Control ToolBox).

Rgds,
Andy
 
G

gus

Perfect, Andy!
I'll create a macro separately, and then I'll copy/paste the code.
Thanks so much!

Gus
 

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

Top