+ Reply to Thread
Results 1 to 11 of 11

Vlookup with more than one condition/value

  1. #1
    Registered User
    Join Date
    07-11-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    20

    Vlookup with more than one condition/value

    I need to find out the price for each part number from Sheet2, and place it on Sheet1.
    Vlookup made sense, however- I have 2 values to look up. The Part Number, and Loc.
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Vlookup with more than one condition/value

    If each combination of values will create a unique set, you can use SumProduct

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Just plop that formula into C2 of Sheet1 as is, and copy downwards. Worked fine for me.
    Last edited by daffodil11; 08-05-2013 at 04:36 PM. Reason: absolute references

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Vlookup with more than one condition/value

    In C1 enter =SUMPRODUCT(--(Sheet2!$A$2:$A$8053=Sheet1!A2),--(Sheet2!$B$2:$B$8053=Sheet1!B2),--(Sheet2!$C$2:$C$8053)) then drag it down

  4. #4
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Vlookup with more than one condition/value

    Array formula confirm COntrl+Shift+Enter
    =IFERROR(INDEX(Sheet2!$C$2:$C$8053,MATCH(A2&B2,Sheet2!$A$2:$A$8053&Sheet2!$B$2:$B$8053,0)),"")
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  5. #5
    Registered User
    Join Date
    07-11-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    20

    Re: Vlookup with more than one condition/value

    Guys, I tried the sumproduct and works perfectly (it does exactly what I need it to do), however it SLOWS DOWN EXCEL tremendously. Approximately 20-30 seconds for ONE calculation.

    Take in mind that in reality, I have 13 worksheets (for 13 months) with raw data (part number, location, quantity and others)
    EAch one is approximately 46k tall, and about 20-30 wide.
    I then have another worksheet which summarizes these 13 sheets, it has basic columns, like part number, location, vendor id, buyer and quantity.
    I do have 13 months, so I am doing a sumproduct every other column for each month, all the way to 46k cells down.

    If i even double click the cell (for auto-calculation), the excel program will freeze.
    I've tried it in excel 2007, 2010, 2013 and in two different computers (one running 4.0ghz i7 quad-core, and 16gb of ddr3).
    It happens on all of them- I have also turned off auto-calculation to MANUAL, however, when it is time to "calculate" IT just freezes. I would have to be doing batches of 10-15 cells down (taking approx. 1-3 min each), which obviously is not going to work.

    ANY IDEAS or any other formula??

  6. #6
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Vlookup with more than one condition/value

    It took about 15 second with my array formula.
    Other suggestion could only be VBA

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,962

    Re: Vlookup with more than one condition/value

    Try with a helper column to eliminate the array.

    In sheet2 D2, copied down...
    =A2&B2

    then in sheet1 use this, copied down...
    =INDEX(Sheet2!$C$2:$C$8053,MATCH(Sheet1!A2&Sheet1!B2,Sheet2!$D$2:$D$8053,0),1)

    To cater for the 13 worksheets, click on the 1st mth tab, hold SHIFT and click on the last month tab (this will GROUP them), then copy that helper down on the 1st sheet - it will be copied down on all sheets. Then click on any other sheet outside of that "group" to ungroup them

    alternatively (and this may even be better) copy ALL data onto 1 sheet (add a month column if needed), and then base the summary on that sheet.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Registered User
    Join Date
    07-11-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    20

    Re: Vlookup with more than one condition/value

    Robert,

    Thank you for your help. I haven't tried your way yet.
    What is formula confirm? Do I press, Ctrl+Shift+Enter, to make it a "array formula"?
    I must admit that on the test sheet, yours worked 50%. I am just confused by your formula.

    ...(INDEX("array" - is where the values im looking for are located
    ...,MATCH(A2&B2 are the values im looking for,"array to look for the values A2/B2"

    Can i use more values after match? Ill just have to expand my array correct? Is there any particular rules for this formula? What if my values are in column H, V and Z ?

    Thank you


    Also, Can you walk me through the index/match?

  9. #9
    Registered User
    Join Date
    07-11-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    20

    Re: Vlookup with more than one condition/value

    Holy MACROS!

    haha, your formual is yet the FASTEST ONE OF THEM ALL (take in mind that i am not at work, so just playing with that test file).

    It does involve an extra step however. So i will try the shift method, to group all the month worksheets, and then do the A2&B2 on the first worksheet so it copies down on ALL worksheets.

    If merge them into one worksheet, I will have to create a month column, which would probably complicate things for the summary worksheet (4 values to look for instead of 3; part/location/price/month) - plus then I will have to transpose.

    Can you further explain your index formula?

    Thank you so much guys, this website is soo much useful than mrexcel....

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,962

    Re: Vlookup with more than one condition/value

    Sure

    there are actually 3 functions in 1 there...Index/match/match

    =index(range,row,column)
    I kept it simple and just used column C as the index range.

    to find the row, I used the MATCH() function
    =Match(Criteria,range,exact/lower/higher)
    =match(...find...A1&A2...this combines the 2 criteria, to match the helper...in the range D2:D8053,0...0=exact match)

    Then for the column, I just ised 1, because the index range has only 1 column.
    =INDEX(Sheet2!$C$2:$C$8053,MATCH(Sheet1!A2&Sheet1!B2,Sheet2!$D$2:$D$8053,0),1)

    This can be expanded on, so that you can pick which column you want to look in, too. Instead of 1 at the end, you could use MATCH() to find a specific column to search in, just like we did with the MATCH() tro find the row to search in

    Hope that helps?

  11. #11
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Vlookup with more than one condition/value

    Quote Originally Posted by cesarmontoya View Post
    Robert,

    Thank you for your help. I haven't tried your way yet.
    What is formula confirm? Do I press, Ctrl+Shift+Enter, to make it a "array formula"?
    I must admit that on the test sheet, yours worked 50%. I am just confused by your formula.

    ...(INDEX("array" - is where the values im looking for are located
    ...,MATCH(A2&B2 are the values im looking for,"array to look for the values A2/B2"

    Can i use more values after match? Ill just have to expand my array correct? Is there any particular rules for this formula? What if my values are in column H, V and Z ?

    Thank you


    Also, Can you walk me through the index/match?
    1) Yes please confirm with Control+Shift+Enter
    2) Yes for INDEX/MATCH locations.
    3) Yes you can use more values after MATCH and you need to expend all arrays
    4) The rules are: INDEX is the column to return MATCH columns to look at- does not matter where they are on spreadsheet.

    FDibbins gave you great alternative but if you can add column before first column in Sheet2 and then concatenate A2&B2 then you can use ordinary VLOOKUP to retrieve your values.
    I'm not sure about efficiency but logic will say:1 function is less than 2.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VLOOKUP with condition
    By [email protected] in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-01-2012, 02:33 AM
  2. [SOLVED] VLOOKUP with a condition
    By vij8y in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-16-2012, 08:16 PM
  3. Vlookup with a condition
    By nicolaforni in forum Excel General
    Replies: 2
    Last Post: 03-05-2012, 07:39 AM
  4. [SOLVED] 2 condition vlookup
    By AZExcelNewbie in forum Excel General
    Replies: 1
    Last Post: 02-17-2006, 06:10 PM
  5. Replies: 1
    Last Post: 11-23-2005, 12:00 PM

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