![]() |
Application.Selection Is Range?
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 |
Application.Selection Is Range?
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 |
Application.Selection Is Range?
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 |
Application.Selection Is Range?
Thank you for your help Bob and Sebastien, much appreciated.
|
Application.Selection Is Range?
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 |
All times are GMT +1. The time now is 04:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com