+ Reply to Thread
Results 1 to 12 of 12

IF VLOOKUP delimma with partial cell values

  1. #1
    Registered User
    Join Date
    02-22-2005
    Posts
    6

    IF VLOOKUP delimma with partial cell values

    Okay, I have a problem with an IF VLOOKUP statement, one that I thought would be handled by setting the range lookup to true (or leaving it blank). It does not. I want to have the formula check in a cell to see if it contains the contents of another cell. The cell it is checking may have other values in it in addition to the contents being looked up. The IF part comes in where IF the formula finds the contents within that cell, it replicates that value. If not, then it says "no". Here's a version of the formula:

    =IF(VLOOKUP(A15,blist,2)=A20,A20,"no")

    - A15 contains a person's name (Meg, in this case)
    - blist is the table array
    - 2 is the column index number I want to check
    - The contents of B8 (the col_index_number cell): blee blow blah
    - Leaving the range lookup blank (or set to TRUE) should find an inexact match

    A20 contains a term ("Blah", in this case)
    IF true, then it displays the contents of A20: "Blah"
    IF false, then it displays "no"

    Well, it only displays "no", unless I *only* have the value "Blah" in the cell. Any other value dumps the formula. I want the formula to look for "Blah" even if "Blee" and "Blow" are in there with it. What am I doing wrong?

  2. #2
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    To use =VLOOKUP(...,...,...,True) the leftmost column in the list (blist) Must be sorted A-->Z (ascending).
    In your example:
    Ann, blee
    Bob, blow
    Cindy, blah
    ....
    True = Close Match: XL will then take the first value below an Exact match (if there is no Exact match).

    Ola Sandstrom
    Last edited by olasa; 02-22-2005 at 06:34 PM.

  3. #3
    Registered User
    Join Date
    02-22-2005
    Posts
    6

    Doesn't work...

    Okay, I re-ordered the text in the cell to read blah blee blow, and I get the same result. I even reversed it just in case (blow blee blah). Same result.

    Is there, perhaps, another method to accomplish what I want?

  4. #4
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Sorry. You were too fast. Read the edited version.
    Ola

  5. #5
    Registered User
    Join Date
    02-22-2005
    Posts
    6

    Now I am confused

    In your example:
    Ann, blee
    Bob, blow
    Cindy, blah


    I do not understand the above. Please elaborate. Does this refer to the index value versus the index number. I'm sorry.

    As a note, if I remove the IF statement, and just have it VLOOKUP, it spits back the contents of the cell, which is fine. All I really want it to do is that when that happens, it gives me a specific result (the name I was looking for), and if it doesn't, that it says "no".

  6. #6
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Hmm, I assumed that:

    =IF(VLOOKUP(A15,blist,2)=A20,A20,"no")
    blist:
    Col A...ColB
    Ann.... blee
    Bob.... blow
    Cindy...blah
    Mary....bluu
    ...

    Example1:
    A15: Mary
    A20: Blah
    =IF(VLOOKUP("Mary",blist,2)="Blah","Blah","no")
    ---> "no"

    Example2:
    A15: Cindy
    A20: Blah
    =IF(VLOOKUP("Cindy",blist,2)="Blah","Blah","no")
    ---> "Blah"


    Ola

  7. #7
    Registered User
    Join Date
    02-22-2005
    Posts
    6
    Quote Originally Posted by olasa

    Example1:
    A15: Mary
    A20: Blah
    =IF(VLOOKUP("Mary",blist,2)="Blah","Blah","no")
    ---> "no"

    Example2:
    A15: Cindy
    A20: Blah
    =IF(VLOOKUP("Cindy",blist,2)="Blah","Blah","no")
    ---> "Blah"


    Ola
    It's still giving me "no", even when the leftmost column all matches up. Is it because it returns the whole value of the cell, so that when the ="Blah" is checked (back to the IF statement), it gets dumped? Is there a way for the lookup result (the whole cell) to be then checked against the desired result ("Blah")? I mean, that seems like what I am doing, and what you are suggesting, but it is still reading as false.

    Okay - Messing around with it clarified some things. It is not the VLOOKUP that is the problem at all. It is the IF statement. I'll work on it tonight...

  8. #8
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    It's getting late here but
    - If XL return the right result from the Vlookup and
    - If there are no extra " " (blanks) "Blah " v.s. "Blah"
    It should work with the rest of the formula

    However, I must admit, I'm not sure I understand... "...the whole value of the cell..." and "...the lookup result (the whole cell)...". I might be missing something important...?

  9. #9
    Registered User
    Join Date
    02-22-2005
    Posts
    6
    Okay, after pondering:

    The VLOOKUP is actually a redundant portion of the formula, as far as what I want is concerned. The important part is the IF statement:

    The cell that is being looked up in the VLOOKUP portion is going to contain more than just "blah". The contents will contain anywhere from two to ten different words, in one single cell. This formula:

    =(VLOOKUP(A15,blist,2,FALSE))

    tells me what is in the second column of the blist group, matched by whatever name is in A15. That could be "blah", but it could be "blah blee blow blue", or whatever other contents are in that cell.

    What I want, however, is for XL to simply determine if "blah" is *anywhere* in that cell, no matter *what else* is in the cell with it. FIND and SEARCH only note the position of said contents, and only if I note just where the text is going to be located in the cell, but they might be of some use (I'm probably just being dense). The IF statement:

    =IF(C16=A20,A20,"no")

    where C16 is the VLOOKUP formula by itself (which, in turn, is just a repeat of what is in the col_index_number), says "no", unless *only* the text for the =A20 is actually true, because VLOOKUP is pulling up all of the data from the cell, not just a piece (because I never asked it to).

    How do I create an IF statement that looks at a cell for just a specific portion of the text, and if that text is there, then I get the true statement, and if not , I get the false statement?
    Last edited by ChrisChandler; 02-23-2005 at 11:10 AM.

  10. #10
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Last try...since I have trouble understand some parts of the problem...


    "What I want, however, is for XL to simply determine if "blah" is *anywhere* in that cell, no matter *what else* is in the cell with it. "

    This might help:
    http://www.excelforum.com/showthread.php?t=348161
    or
    =IF(COUNTIF(Range,"*blah*")>0,"Found","Nothing")

    Ola Sandstrom

  11. #11
    Registered User
    Join Date
    02-22-2005
    Posts
    6
    Quote Originally Posted by olasa
    Last try...since I have trouble understand some parts of the problem...


    "What I want, however, is for XL to simply determine if "blah" is *anywhere* in that cell, no matter *what else* is in the cell with it. "

    This might help:
    http://www.excelforum.com/showthread.php?t=348161
    or
    =IF(COUNTIF(Range,"*blah*")>0,"Found","Nothing")

    Ola Sandstrom
    Thank you! I only had to modify the field "*blah*" to "**"&A20&"**", and I get exactly what I need.
    Good deal - I appreciate your help, and your patience.
    Chris
    Last edited by ChrisChandler; 02-23-2005 at 05:19 PM.

  12. #12
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Good to hear.
    Thanks.
    Ola

+ 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