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/334606-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?

Thanks.

--
|
+-- Thief_
|



Norman Jones

Detect which shape was clicked....
 
Hi Thief,

Try assigning ththe following macro to each of thre rectangles:

Sub TestRectangles()

Select Case Application.Caller
Case "Rectangle 1"
'Do something
MsgBox Application.Caller '<<=== Demo only
Case "Rectangle 2"
'Do something
MsgBox Application.Caller '<<=== Demo only
Case "Rectangle 3"
'Do something
MsgBox Application.Caller '<<=== Demo only
End Select

End Sub


Change the names of the rectangles to accord with your names.

Replace the 'Do something lines with your desired actions.

The MsgBox lines are purely for demo purposes; click the rectangles and
test.


---
Regards,
Norman



"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?

Thanks.

--
|
+-- Thief_
|





Thief_

Detect which shape was clicked....
 
TOP post Norman!!

--
|
+-- Thief_
|

"Norman Jones" wrote in message
...
Hi Thief,

Try assigning ththe following macro to each of thre rectangles:

Sub TestRectangles()

Select Case Application.Caller
Case "Rectangle 1"
'Do something
MsgBox Application.Caller '<<=== Demo only
Case "Rectangle 2"
'Do something
MsgBox Application.Caller '<<=== Demo only
Case "Rectangle 3"
'Do something
MsgBox Application.Caller '<<=== Demo only
End Select

End Sub


Change the names of the rectangles to accord with your names.

Replace the 'Do something lines with your desired actions.

The MsgBox lines are purely for demo purposes; click the rectangles and
test.


---
Regards,
Norman



"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?

Thanks.

--
|
+-- Thief_
|








All times are GMT +1. The time now is 01:55 AM.

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