ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Detect which shape was clicked? (https://www.excelbanter.com/excel-programming/334605-detect-shape-clicked.html)

Thief_

Detect which shape was clicked?
 
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?

--
|
+-- Thief_
|



Rob Bovey

Detect which shape was clicked?
 
"Thief_" wrote in message
...
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




All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com