+ Reply to Thread
Results 1 to 6 of 6

Combining If statement and vlookup

  1. #1
    Registered User
    Join Date
    04-05-2011
    Location
    Denver, CO
    MS-Off Ver
    Excel 2003
    Posts
    4

    Combining If statement and vlookup

    I am trying to look up a value and return the value in the next column, however if the lookup value does not appear, then lookup the value in a seperate column. I have excel 2003.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Combining If statement and vlookup

    Probably need more info on your data setup. In any case, it will be something like this.....

    = IF(ISNUMBER(MATCH(A1, Data!$A$1:$A$50,0)),VLOOKUP(A1, Data!$A$1:$B$50,2,FALSE),VLOOKUP(A1, Data!$A$52:$B$102,2,FALSE))
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

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

  3. #3
    Registered User
    Join Date
    03-26-2010
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Combining If statement and vlookup

    Hi Wildcat,

    It's a little tricky to explain without sample data, but if you could use something like the following if your lookup value was in A1 (I'm searching for "a" in this example), and your data is in B1 and C1 (2 and 3, respectively).

    If you wanted to return the second column when A1 is "a", but return the third column when A1 is not "a", you could use the following:

    =IF(A1="a",VLOOKUP("a",A1:C1,2,FALSE),IF(A1<>"a",VLOOKUP(A1,A1:C1,3,FALSE)))

    Hope that helps,
    David

  4. #4
    Registered User
    Join Date
    04-05-2011
    Location
    Denver, CO
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combining If statement and vlookup

    Thanks chemistB that worked great for me. If I wanted to search additional columns beyond the two, would I just add the additional vlookups to look at the additional columns, or would I have to add any other logic.

    Thanks again.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Combining If statement and vlookup

    Quote Originally Posted by ChemistB View Post
    Probably need more info on your data setup. In any case, it will be something like this.....

    = IF(ISNUMBER(MATCH(A1, Data!$A$1:$A$50,0)),VLOOKUP(A1, Data!$A$1:$B$50,2,FALSE),VLOOKUP(A1, Data!$A$52:$B$102,2,FALSE))
    Does that work for you?

    Maybe replacing the
    Please Login or Register  to view this content.
    part with
    Please Login or Register  to view this content.
    would make the calculation faster ? ( if needed)

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Combining If statement and vlookup

    You could add additional IF statements (nesting). Excel 2003 has a limit of 7. Depending on your data set up, there may be simplier ways.

+ 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