Detect which shape was clicked?

T

Thief_

IF I have 3 autoshapes, rectangles, on a worksheet, how do I detect which
shape was clicked by the user so that I can, say, delete it or change its
properties?
 
R

Rob Bovey

Thief_ said:
IF I have 3 autoshapes, rectangles, on a worksheet, how do I detect which
shape was clicked by the user so that I can, say, delete it or change its
properties?

If you assign the same macro to all of them, Application.Caller will
return the name of the shape that fired the macro. You can then use
Worksheets("Whatever").Shapes("CallerName") to get an object reference to
that shape.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 

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