+ Reply to Thread
Results 1 to 8 of 8

Lookup value based on IF

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2008
    Location
    PA
    Posts
    33

    Lookup value based on IF

    Good morning.. here is my delema...

    cat ---- dog ---- apple ---- orange
    1 ------ 4 ------ 7 ------- 10
    3 ------ 6 ------ 9 ------- 12

    The above is a simplified example of waht i'm trying to do...

    basically i have a value say (5) I want to check if its in the range of the numbers and return the value in a certain row...

    So basically If the value is bigger than whats in the second row and smaller than whats in the third row return the corrosponding value in the first row

    in this case for (5) it would be dog... i tried doing this with multiple if statements but i have about 15 columns of info and it tells me that the formula is too big...

    Thanks in advance!
    Last edited by VBA Noob; 11-07-2008 at 04:50 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719
    If your data is in A1:D3 and lookup value [5] in E2 use this formula in F2

    =LOOKUP(E2,A2:D2,A1:D1)

    As you can see row 3 isn't used, it's not necessary if your ranges are contiguous

  3. #3
    Registered User
    Join Date
    11-07-2008
    Location
    PA
    Posts
    33
    thats great! it worked to solve the problem but i should elborate on the actaul application becuase it is a little more advanced than that!

    -------Dog-------Cat--------Apple
    -------1----------3-----------5
    -------3----------5-----------7
    -------MIX1------MIX1-------MIX1
    X-------965--------580--------658
    Y-------568--------432--------745
    Z-------325--------486--------423
    -------MIX2------MIX2-------MIX2
    X-------220--------256---------856
    Y-------623--------246---------875
    Z-------260--------456---------623
    -------MIX3------MIX3-------MIX3
    X-------658-------756--------985
    Y-------123-------732--------432
    Z-------638-------754--------231

    So i have 3 refrences... lets say 6 and mix 2 and Y

    So i need 875 returned...

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719
    That probably isn't the best layout to achieve what you want but you can do that as per the attached. Note that X, Y and Z must be in the same order on each section
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    I did it similarly to the way DLL did it but I set up defined names for each table (Mix1, Mix2, Mix3) and with the indirect function, pointed the INDEX function in the right direction. With your variables in B18,19 and 20, the formula becomes
    '=INDEX(INDIRECT(B19),MATCH(B20,A5:A7,0),MATCH(B18,B2:D2,1))
    This assumes that the variable down column A (X,Y,Z) is the same for all mixes. See Attached.
    Attached Files Attached Files
    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

  6. #6
    Registered User
    Join Date
    11-07-2008
    Location
    PA
    Posts
    33

    revised lookup

    Thanks the file you sent was really helpfull... I want to add another refrence now... i've attached an excel file... solving this should take care of the entire problem!

    Thanks in advance
    Attached Files Attached Files

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719
    Try this formula in F24

    =INDEX(B4:D21,MATCH(C24,B4:B21,0)+MATCH(E24,B5:B21,0)+MATCH(D24,A6:A8,0),MATCH(B24,B2:D2,1))

  8. #8
    Registered User
    Join Date
    11-07-2008
    Location
    PA
    Posts
    33
    wow amazing thank you

+ 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