ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Understanding Selection "Type" (https://www.excelbanter.com/excel-programming/289853-understanding-selection-type.html)

MWE[_27_]

Understanding Selection "Type"
 
How can one determined what "type" of selection has been made? Since a
selection could be a range, a shape, a chartobject, etc., how do you
know which type and how can you determine which particular instance of
that type?

Thanks


---
Message posted from http://www.ExcelForum.com/


Rob van Gelder[_4_]

Understanding Selection "Type"
 

TypeName is what you're after:

Sub test()
MsgBox TypeName(Selection)
End Sub

Another way is:
If TypeOf Selection Is Rectangle Then MsgBox "Selection is a Rectangle"


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"MWE " wrote in message
...
How can one determined what "type" of selection has been made? Since a
selection could be a range, a shape, a chartobject, etc., how do you
know which type and how can you determine which particular instance of
that type?

Thanks


---
Message posted from http://www.ExcelForum.com/




MWE

Understanding Selection "Type"
 
Ron: Your reply was most helpful. However, I still can
not quite do what I want. Assume a worksheet on which
there are various objects, e.g., charts, pictures,
textboxes, rectangles, etc. I wish to be able to select
any of these objects and know its "type" (you already
showed me how to do that) and be able to work with that
specific object. For a range or chart, working with the
selected object is understood (active cell, activechart,
etc). But for a item that the worksheet includes in its
collection of shapes, I do not know how to identify the
specific instance.

Thanks
-----Original Message-----

TypeName is what you're after:

Sub test()
MsgBox TypeName(Selection)
End Sub

Another way is:
If TypeOf Selection Is Rectangle Then

MsgBox "Selection is a Rectangle"


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"MWE " wrote in

message
...
How can one determined what "type" of selection has

been made? Since a
selection could be a range, a shape, a chartobject,

etc., how do you
know which type and how can you determine which

particular instance of
that type?

Thanks


---
Message posted from http://www.ExcelForum.com/



.



All times are GMT +1. The time now is 12:06 PM.

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