How to I reference in VB a button used to run an Excel macro

G

Guest

Is there a way to reference objects in a VB macro that have been assigned the
same macro?

My application involves several different objects in a worksheet used to
launch a macro that differs only slightly depending on which object is
clicked. If I can ID the object in the code, I can combine the different
macros and just include some IF..THEN statements relating to the object
clicked.

Thx...
 
D

Dave Peterson

Maybe you can use application.caller to get the name of the object.

Add

Msgbox application.caller

to the top of your code and you'll see the names you should use to compare.
 
G

Guest

If the objects are shapes or controls from the control toolbox you can use
application.caller

sName = application.caller

sName will hold the name of the object.
 

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