+ Reply to Thread
Results 1 to 4 of 4

Nested IF/OR with VLOOKUP

  1. #1
    Registered User
    Join Date
    09-21-2009
    Location
    AZ
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    12

    Thumbs up Nested IF/OR with VLOOKUP

    I'm trying to build this formula and I'm only half way through it and it already isn't working.

    Column D - can be 1, 2, 3, or 4
    Column E - can be any number

    If column D is 1 or 3, then the VLOOKUP should look up column E and point to the answer in column 4 on another worksheet (Companies in this case).

    If column D is 2 or 5, then the VLOOKUP should look up column E and point to the answer in column 5 on another worksheet (Companies in this case)..

    This is what I have so far, just trying to get it to recognize if it is a 1 or 2:

    =IF(OR(D2=1,VLOOKUP(E2,Companies!A:G,4)),IF(D2=2,VLOOKUP(E2,Companies!A:G,5)))

    What is making this not work? I'm getting a false. But before I added the OR, it worked for the D2=1.

    Thanks.

    Alisa

    Last edited by alisapooh; 09-24-2009 at 12:54 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Nested IF/OR with VLOOKUP

    try:

    =VLOOKUP(E2,Companies!A:G,IF(OR(D2={1,3}),4,5),FALSE)

    or

    =VLOOKUP(E2,Companies!A:G,IF(MOD(D2,2)=1,4,5),FALSE)
    Last edited by NBVC; 09-24-2009 at 12:37 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Nested IF/OR with VLOOKUP

    Hi Alisa, try either:

    =VLOOKUP(E2,Companies!A:G,LOOKUP(D2,{1,2,3,4},{4,5,4,5}),0)

    or

    =IF(OR(D2=1,D2=3),VLOOKUP(E2,Companies!A:G,4,0),IF(OR(D2=2,D2=4),VLOOKUP(E2,Companies!A:G,5,0),""))

  4. #4
    Registered User
    Join Date
    09-21-2009
    Location
    AZ
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    12

    Re: Nested IF/OR with VLOOKUP

    you guys are AWESOME!! It worked perfectly!! Thanks!!

+ 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