Beginners Allowed?? Macro Question

R

RobinH

Found this website googling help with macros and assigning to a button.
What I'm trying to accomplish is within a worksheet to have severa
control buttons that would run a sort macro. Pretty basic such a
sorting by zip codes, cities, state. I'm guessing that the butto
would be an ActiveX control. I know how to record & name a macro but
can't make it work to assign a macro to an ActiveX button. I was abl
to create a button and name it but assigning a macro to it is mor
complicated and I don't understand the instrux from the Help that
printed out. It looks like it gets into Visual Basic coding. What
read was about starting a macro from a button or graphic control and i
seemed to read that it was as easy as right clicking on the button an
choosing assign macro. That option to assign macro didn't come up.
I'm lost....can someone put me in the right direction. I'm not
programmer (obviously), just trying to improve functionality of
spreadsheet. Thanks for any help that anyone can give!!

Robi
 
A

A.W.J. Ales

Robin,

You probably took a button from the Control Toolbar. If you take a
button from the Forms Toolbar itwill give you the opportunity to assign a
macro to it by right clicking on it (if not directly by "dragging" it from
the toolbar to your sheet.


--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *
 
H

Harald Staff

Hi Robin

Adding to Auk's advice (Forms buttons):

ActiveX buttons already have lots of empty macros assigned to them. They are found in the
container's module (which is either the Worksheet module or the Userform module). The most
used macro code is Click:

Private Sub CommandButton1_Click()

End Sub

And you start other macros with it by calling them from this one

Private Sub CommandButton1_Click()
Call Macro1
End Sub
 
E

Earl Kiosterud

Robin,

ActiveX have all kinds of events, with preassigned macros, as Herald has
mentioned. You can also use just about any graphic (like a shape from the
Drawing Toolbar, a WordArt, or an inserted picture or clip art (Insert -
Picture))and use the right mouse to assign it to your macro. In this case,
your macro would be in a regular module.
 

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