Consulting

Results 1 to 11 of 11

Thread: Compare one cell with a range ....

  1. #1

    Compare one cell with a range ....

    Hello,

    How can I compare one cell with a range ?? ... Something like: if A1 value is through b1:b100 values to get an "ok" ...

    Thx,
    Nedy

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Quote Originally Posted by nedy_03
    Something like: if A1 value is through b1:b100 values to get an "ok" ...
    Can you clarify this statement......I don't understand.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =IF(ISNUMBER(MATCH(A1,B1:B100),0)),"ok","")

    perhaps

  4. #4
    What does that "0" do ?? cause I get an error on it ? ..

    Thx,
    Nedy

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    It is for an exact match. Bob misplaced a paren...

    =IF(ISNUMBER(MATCH(A1,B1:B100,0)),"ok","")

    HTH

  6. #6
    I'll try to explain better what I'm looking for .. In the attach file in "C1" I would need a formula that looks through the "B1:B18" values. And if one of the "B1:B18" values match the A1 value, in "C1" I should get on "OK" ...

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Without looking at your file, in C1, enter this formula...

    =IF(ISNUMBER(MATCH(A1,B1:B18,0)),"OK","NOT OK")

    HTH

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Doesn't Zack's correction do exactly that? Post #5
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    AND IF I HAVE TO APPLY THIS FOR TEXT .. CAN I USE "ISTEXT" INSTEAD OF "ISNUMBER" ?? ... I TRIED IT AND IF I USE "ISNUMBER" IT WORKS FOR TEXT TOO ... BUT "ISTEXT" ITDOESN'T WORK ...

    THX,
    NEDY

  10. #10
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Because ISTEXT() does not see if the MATCH() function found a match or not, as MATCH() returns a numeric position of (with the 0 in the third syntax) the matched value. You cannot switch it out that way. The function works exactly as you requested.

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by firefytr
    It is for an exact match. Bob misplaced a paren...

    =IF(ISNUMBER(MATCH(A1,B1:B100,0)),"ok","")

    HTH
    I spotted that and thought I corrected it before I posted

Posting Permissions

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