Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I determine if the Application.Selection is a Range type object?
Is there a way test way to test like this: If Application.Selection Is Range Then 'Then do some thing with the range. End If |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jeff,
Try something like this Dim rng As Range On Error Resume Next Set rng = Application.Selection On Error GoTo 0 If rng Is Nothing Then MsgBox "Not a r5ange" End If -- HTH RP (remove nothere from the email address if mailing direct) "Jeff Higgins" wrote in message ... How can I determine if the Application.Selection is a Range type object? Is there a way test way to test like this: If Application.Selection Is Range Then 'Then do some thing with the range. End If |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
you can use the TypeName function which returns the 'class' name as a string of the object or value: in your case, if it is a range TypeName(Application.Selection) returns "Range". That is : If TypeName(Application.Selection)="Range" Then '... Endif Regards, Sebastien "Jeff Higgins" wrote: How can I determine if the Application.Selection is a Range type object? Is there a way test way to test like this: If Application.Selection Is Range Then 'Then do some thing with the range. End If |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you for your help Bob and Sebastien, much appreciated.
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the TypeOf operator. E.g.,
If TypeOf Selection Is Excel.Range Then Debug.Print "range" Else Debug.Print TypeName(Selection) End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jeff Higgins" wrote in message ... How can I determine if the Application.Selection is a Range type object? Is there a way test way to test like this: If Application.Selection Is Range Then 'Then do some thing with the range. End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why does Selection.PasteSpecial toggle Application.ScreenUpdating | Excel Worksheet Functions | |||
Narrow Range based on Selection in Another Range | Excel Discussion (Misc queries) | |||
Identifying a selection of a selection of a range | Excel Worksheet Functions | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming | |||
VBA application; Subscript Out of Range | Excel Programming |