+ Reply to Thread
Results 1 to 7 of 7

Vlookup based on 4 variables

  1. #1
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Vlookup based on 4 variables

    I have a 4 column worksheet with number ranges in each column then a 5th column with a letter assignment so that if my 4 numbers fall in the range the letter will be returned. For example:

    A B C D Grade
    100 500 150 600 A
    110 550 175 610 B
    120 600 200 620 C

    So if my numbers are A =107; B=545; C= 162;D= 601 then my grade will be a B since all the numbers are <= to the numbers in that row. It gets a bit more complicated than that as there are over 20,000 combinations but that is the jist of it. Any solutions?
    Last edited by NBVC; 02-27-2012 at 12:06 PM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Vlookup based on 4 variables

    I put your four values in cells F1,G1,H1 and I1 and then used this formula:

    =INDEX(E:E,MAX(INDEX(ROW(A1:A3)*(A1:A3<=F1)*(A2:A4>F1)*(B1:B3<=G1)*(B2:B4>G1)*(C1:C3<=H1)*(C2:C4>H1)*(D1:D3<=I1)*(D2:D4>I1),0)))

    Is that what you're looking for?

    Edited to add: Forgot to mention, this solution requires a 'dummy' row 4 to work. In A4 I put the formula =MAX(A1:A3)+1 and copied this across. The dummy row should have values higher than all of the other rows to work, so you can just use an arbitrarily large value.

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

    Re: Vlookup based on 4 variables

    If your inputs are in H1:K1 and your data in A2:D4, perhaps:

    =INDEX($E$2:$E$4,MATCH(1,INDEX((A2:A4>=H2)*(B2:B4>=I2)*(C2:C4>=J2)*(D2:D4>=K2),0),0))

    adjust ranges to suit.
    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.

  4. #4
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Re: Vlookup based on 4 variables

    That is close to what I need however the numbers can repeat for the different combinations so in my column A I may have 110 20 different times.

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

    Re: Vlookup based on 4 variables

    Are you talking about both offered formulas?

    Can you post a worksheet showing representative examples and some expected results?

  6. #6
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Vlookup based on 4 variables

    It shouldn't matter how many times a value repeats, the formula from both NBVC and myself should still work.

  7. #7
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Re: Vlookup based on 4 variables

    Thanks NBVC. That worked perfectly!

+ 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