+ Reply to Thread
Results 1 to 3 of 3

Difference between Intersect and Not Intersect is Nothing

  1. #1
    Registered User
    Join Date
    12-05-2006
    Location
    Philadelphia PA
    MS-Off Ver
    Office 365
    Posts
    81

    Difference between Intersect and Not Intersect is Nothing

    My app uses Worksheet_Change(ByVal, Target as Excel.Range)

    To narrow the scope of the event I then use either:

    Please Login or Register  to view this content.
    The large majority of code samples that I've seen for the Change Event all use the first form. Yet intuitively I would expect the 2nd form to be operationally identical since NOT and IS NOTHING appear to cancel each other. And because it eliminates NOT and IS NOTHING, the 2nd form ought to be more efficient. In fact, in my application the 2nd form seems to do the same thing and work just as well. Is there some gotcha or subtle distinction between the two forms that I should be aware of?
    Last edited by batman; 11-13-2009 at 05:40 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Difference between Intersect and Not Intersect is Nothing

    Hello Batman,

    The comparator statement Is Nothing is used exclusively with objects. Target is a Range object and Intersect returns either a Range object, if true, or Nothing.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-05-2006
    Location
    Philadelphia PA
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Difference between Intersect and Not Intersect is Nothing

    Thanks Leith, that helps.

    While pondering your response and studying my code, I realized that I don't need the Intersect code line at all. I already know the range (Trading) where the changes take place, and with or without the Intersect statement I can deal explicitly with the consequences of the specific change. Using Worksheet_Change simply tells me when to take that action. So I commented out the If.....Intersect..... line and its mating End If, and everything worked fine - same results as before. I'll mark the thread solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1