+ Reply to Thread
Results 1 to 6 of 6

Change Vlookup to lookup against 2 criterias

  1. #1
    Forum Contributor
    Join Date
    01-14-2010
    Location
    England
    MS-Off Ver
    2013
    Posts
    110

    Change Vlookup to lookup against 2 criterias

    Hi,

    I have had help on this forum recently creating a formula that does a vlookup and based on the returned value will change what is displayed (Post: http://www.excelforum.com/showthread.php?t=1169860)
    I'm hoping to change this formula to lookup against 2 criterias rather than just one.

    Currently the vlookup looks up from Sheet 1 column A to Sheet 2 column A and returns sheet 2 column b however i would now like to update this to lookup from Sheet 1 column A+H to Sheet 2 column A+H and return sheet 2 column b.

    Reason being, I may have duplicate SKU's in column A but where i have a duplicate SKU the batch number in column H will be different, see attached spreadsheet for example.

    Rows 2 and 6 have the same SKU but different batch numbers, based on the rules row 2 should return BER (which it does correctly) however row 6 should return WUR.

    Can anyone help with this please?

    Cheers,
    Jamie
    Last edited by JDobbsy1987; 01-19-2017 at 06:19 PM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Change Vlookup to lookup against 2 criterias

    One way

    Create a combined column on both sheet1 and sheet2 concatenating the values from columns A & H
    In row2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Use the new columns for the match

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,737

    Re: Change Vlookup to lookup against 2 criterias

    You need to change the formula in K2 of Sheet1 to this array* formula:

    =IF(LEN(INDEX('Sheet 2'!$B$2:$B$6,MATCH(1,('Sheet 2'!$A$2:$A$6=A2)*('Sheet 2'!$H$2:$H$6=H2),0)))=15,"WUR",INDEX('Sheet 2'!$B$2:$B$6,MATCH(1,('Sheet 2'!$A$2:$A$6=A2)*('Sheet 2'!$H$2:$H$6=H2),0)))

    and then you can copy it down.

    *Please note that an array formula needs to be committed using the key combination of Ctrl-Shift-Enter (CSE) rather than the usual < Enter >.


    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    09-18-2014
    Location
    Lansdale, Pa
    MS-Off Ver
    2007 and 2010
    Posts
    7

    Re: Change Vlookup to lookup against 2 criterias

    I agree with Kev_. I use the method of combining fields to validate tens of thousands of lines at work all the time and this is the easiest way to do it without making a supper long and complex formula. See the attached file.
    Last edited by tomm8810; 01-19-2017 at 08:50 PM.

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Change Vlookup to lookup against 2 criterias

    I am rather terrified of array formulas, but that's because I have never learnt how to construct them properly"

    @tomm8810's - your post got me thinking about relative file sizes etc - and I was surprised by the result.

    Using @JDobbsy1987's file and increasing the data to approx 5000 rows in both sheets 1 & 2:
    with original formula : file size = 682kb,
    with @Pete_UK's solution : file size = 754kb (more complex formula)
    with @kev_'s solution : file size = 751kb (2 additional columns of "simple" formula)

    Isn't Excel great - so many ways to cook the cake!
    My new year resolution for 2017 - get to grips with array formula

  6. #6
    Forum Contributor
    Join Date
    01-14-2010
    Location
    England
    MS-Off Ver
    2013
    Posts
    110

    Re: Change Vlookup to lookup against 2 criterias

    Thank you for the replies, i did get it working using the method posted by Kev to begin with but will look into the array formula too.

    Thank you very much for your support.

    Cheers,
    Jamie

+ 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. Lookup values based on two criterias
    By sagarh in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-13-2015, 07:49 AM
  2. [SOLVED] LookUp Text by two criterias
    By dLhx in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-25-2015, 04:36 PM
  3. [SOLVED] Lookup for 2 criterias in 3 sheets.
    By thilag in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-26-2015, 11:30 PM
  4. Lookup with 2 different criterias
    By frostie77 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-13-2012, 10:14 AM
  5. 2 Criterias, 2 Sheets lookup?
    By banquo_ws in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-24-2007, 01:35 PM
  6. [SOLVED] Vlookup doesn't work until i edit(but not change) the lookup cell
    By Confused in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2005, 05:25 AM
  7. [SOLVED] Lookup with 3 criterias
    By Ginger in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-30-2005, 05:06 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