+ Reply to Thread
Results 1 to 11 of 11

Multiple Vlookups

  1. #1
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Question Multiple Vlookups

    Hello all,

    I'm trying to lookup 2 different values in another workbook and return a value based on the conditions in other columns.

    For example:

    In sheet1:
    A1 = abc
    B1 = 01

    In sheet2:

    somewhere in column A is 3 or 4 occurrences of ABC
    somewhere in column B within those 3 or 4 occurrences are 1 or 2 occurrences of 01 next to it.
    In the 1 or 2 occurrences where A and B match up on the same row (lets say this happens in row 995 for example's sake), I now need to look at column C row 995, if there's a number >0, use the number in column D, else use the number in column E.

    Hopefully that makes sense. Thanks.
    Last edited by madadd; 09-16-2011 at 01:19 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Multiple Vlookups

    nope not at all, attach a workbook showing example/s of what you want/don't want
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,318

    Re: Multiple Vlookups

    Something like:

    =INDEX(Sheet2!$C$1:$C$100,MATCH(A1&B1,Sheet2!$A$1:$A$100&Sheet2!$B$1:$B$100,0))

    Array entered with Ctrl-Shift- Enter rather than just Enter.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Multiple Vlookups

    I've attached an example. Sheet2 represents the other workbook.
    Attached Files Attached Files

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,318

    Re: Multiple Vlookups

    Example 1:

    =IF(ISERROR(MATCH(A2&B2,Sheet2!$A$1:$A$100&Sheet2!$B$1:$B$100,0)),"Not Found",IF(INDEX(Sheet2!$C$1:$C$100,MATCH(A2&B2,Sheet2!$A$1:$A$100&Sheet2!$B$1:$B$100,0))>0,INDEX(Sheet2!$D$1:$D$100,MATCH(A2&B2,Sheet2!$A$1:$A$100&Sheet2!$B$1:$B$100,0)),INDEX(Sheet2!$E$1:$E$100,MATCH(A2&B2,Sheet2!$A$1:$A$100&Sheet2!$B$1:$B$100,0))))

    Array Entered.

    I'll leave you to translate that for example 2 ;-)

    Regards

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,318

    Re: Multiple Vlookups

    Example 2, to save you some time:

    =IF(ISERROR(MATCH(A7&B7,Sheet2!$A$1:$A$100&Sheet2!$I$1:$I$100,0)),"Not Found",IF(INDEX(Sheet2!$J$1:$J$100,MATCH(A7&B7,Sheet2!$A$1:$A$100&Sheet2!$I$1:$I$100,0))>0,INDEX(Sheet2!$K$1:$K$100,MATCH(A7&B7,Sheet2!$A$1:$A$100&Sheet2!$I$1:$I$100,0)),INDEX(Sheet2!$L$1:$L$100,MATCH(A7&B7,Sheet2!$A$1:$A$100&Sheet2!$I$1:$I$100,0))))

    Array Entered

    Regards

  7. #7
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Multiple Vlookups

    Excellent! Thank you TMShucks. It took a little to work out the conversion to my actual sheet and snuff out the syntax errors, but that's done and it works great. One very small complaint, I don't suppose it's possible to use entire column references? I tried and it error-ed out on me. I tried something simple even like:
    Please Login or Register  to view this content.
    and no go. I assume it has something to do with array references, but whatever. Easy workaround.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,318

    Re: Multiple Vlookups

    You're welcome. Thanks for the rep.

    You can probably do whole column references in 2007+ but it wouldn't be recommended.

    If you think about it, you're multiplying two columns of 64000+ entries so it will be slow and memory hungry ... even more so with over a million rows in 2007.

    Regards

  9. #9
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Multiple Vlookups

    I don't know if this is abiding by forum rules (I dind't find anything in there) but I have a follow up question.

    So based on your eloquent formula, I've modified it to the following:
    Please Login or Register  to view this content.
    What I need to do is further modify the section:
    Please Login or Register  to view this content.
    I realized I can't point at just this column (the S column). I need to choose between 13 different columns based on a value I have in the current worksheet, column H. Column H (located in the worksheet where the formula is, not the 090911 FGI.xls) is going to contain the correct column title for which to search:
    Please Login or Register  to view this content.
    So, I thought about using an Hlookup, and I came up with
    Please Login or Register  to view this content.
    This mostly gives me an #N/A error, but sometimes it works...very weird can't figure out the pattern of why or why not. So maybe some kind of integration between this and the original?

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,318

    Re: Multiple Vlookups

    I don't know if this is abiding by forum rules (I dind't find anything in there) but I have a follow up question.
    Strictly, no ... and you would be better starting a new thread and providing a cross reference back. That way, you're likely to get more input from a wider group of people.

    Regards

  11. #11
    Registered User
    Join Date
    02-04-2011
    Location
    boulder, co
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: Multiple Vlookups

    Oy, thnx and done.

+ 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