SOLVED VBA: How to test if an object (range) is nothing?

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: SOLVED VBA: How to test if an object (range) is nothing?

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Posts
    113
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I perform an intersection, but sometimes the result is nothing. I have not been able to find a means to test if isect is nothing.

    Set isect = Application.Intersect(SourceSelection, Range("A10:A65000"))

    I want the equivalent to:
    If isect = "nothing" then msgbox "No relevant data."

    Thanks.

    [ This Message was edited by: Brian on 2002-05-20 14:47 ]

    [ This Message was edited by: Brian on 2002-05-20 17:23 ]

  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello Brian, perhaps the following procedure will be of use:


    Sub SrcSel()
    Dim SourceSelection As Range
    Set SourceSelection = Selection 'Change this to your preference
    If Not Application.Intersect(SourceSelection, _
    Range("A10:A65000")) Is Nothing Then
    MsgBox "No relevant data."
    End If
    End Sub


    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-05-20 15:41 ]

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Posts
    113
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks.

    Sorry, oversight on my part.

    I had tried "isnothing" as one word instead of two.

    Thanks again,

    Brian

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com