Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Application.Selection Is Range?

Thank you for your help Bob and Sebastien, much appreciated.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does Selection.PasteSpecial toggle Application.ScreenUpdating OssieMac Excel Worksheet Functions 2 August 4th 09 12:05 AM
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM
VBA application; Subscript Out of Range M J Excel Programming 8 December 30th 03 01:38 AM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"