+ Reply to Thread
Results 1 to 5 of 5

Compare what cell is stored in a Range variable.

  1. #1
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Compare what cell is stored in a Range variable.

    How would i get something like the following code to work? Right now it returns true no matter what, when this should always be false.

    Please Login or Register  to view this content.
    Last edited by GaidenFocus; 07-12-2012 at 03:06 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Compare what cell is stored in a Range variable.

    GaidenFocus,

    Right now that code is checking the values against each other. If both A2 and A3 are blank, it will return True. To see if a cell is part of another range, you'll need to use the Intersect method.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Compare what cell is stored in a Range variable.

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    since both are single cells
    Remember what the dormouse said
    Feed your head

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Compare what cell is stored in a Range variable.

    It works perfect for me.

    Please Login or Register  to view this content.
    You are here asking if the value in A2 = the value in A3.

    When I ran the code, if A2 = A3 then the msgbox gave "True" else "False"!

  5. #5
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Compare what cell is stored in a Range variable.

    Thanks romper and tiger the intersect method worked just like i needed it to. Steve, i was not trying to compare the values in the cells, i was trying to compare the range stored in the variable.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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