+ Reply to Thread
Results 1 to 5 of 5

Match multiple criteria and return multiple values.

  1. #1
    Registered User
    Join Date
    10-06-2017
    Location
    California
    MS-Off Ver
    2013
    Posts
    2

    Match multiple criteria and return multiple values.

    Hello everyone. I’ve been looking through the message board for a few days now trying to piece together a formula that will do what I state below, but I haven’t been able to get anything I’ve found to work exactly right.

    I need a formula that will:
    1. Match three separate criteria from two separate workbooks,
    2. Return the values on separate rows for each set of criteria matched,
    3. and return different subsequent values found even if the criteria matched is the same.

    I need to match the values in:
    1. Book1-ColumnA = Book2 ColumnA
    2. Book1-ColumnC = Book2 ColumnB
    3. Book1-ColumnE = Book2 ColumnC

    And return the value from:
    1. Book2-ColumnD to Book1-ColumnH

    These are a couple of the formulas I’ve tried:
    1.=INDEX([Book2.xlsx]Sheet2!$D$2:$D$7,SMALL(IF(COUNTIF($A$2:$A$7,[Book2.xlsx]Sheet2!$A$2:$A$7),MATCH(ROW([Book2.xlsx]Sheet2!$A$2:$A$7),ROW([Book2.xlsx]Sheet2!$A$2:$A$7)),""),ROWS($A$1:A1)))

    2.=INDEX([Book2.xlsx]Sheet2!$A$1:$D$7,MATCH(1,([Book2.xlsx]Sheet2!A:A=A2)*(LEFT([Book2.xlsx]Sheet2!B:B,4)=C2)*([Book2.xlsx]Sheet2!C:C=E2),0),4)

    In the attached workbook, and the screenshots below, the first formula is returning the correct results, see H2 and H3, but it’s only matching on a single criteria in column A and I’m not even sure that part is working correctly because changing the value in column A doesn’t cause the formula to error out. And the second formula in column I is the one that is working the best by matching on all three criteria, but it only returns the first value it finds, see I2 and I3.

    Other information that might be important:
    1. I’m going to be inserting this formula using a macro and making it copy down.
    2. And I’m going to have it look for and correct errors and then loop back through to recalculate.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Match multiple criteria and return multiple values.

    Hi,
    It's not clear to me what the final result should look like. If you'd like to mock up a set of results maybe I can help further.

    In general though if you want to match several fields in one range to the same fields in another range and identify the matches/non matches then the usua technique is to add helper columns to concatenate the field values into a single text string in the helper column and then match on the helper column.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Match multiple criteria and return multiple values.

    Hi lodewyj. Welcome to the forum.

    You can try modifying your formula in I2 to capture the second matching items and error when appropriate. However this formula is limited to only capturing and returning 2 items. It does not have to be array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    To capture and return more than that try array entering this formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  4. #4
    Registered User
    Join Date
    10-06-2017
    Location
    California
    MS-Off Ver
    2013
    Posts
    2

    Re: Match multiple criteria and return multiple values.

    Hi guys,

    Thank you for the quick replies. This thing has been driving me nuts.

    Richard, I'm looking for the results that are in column H (Test 1) on the first sheet/screenshot; they match column D from the second sheet/screenshot. Originally I had tried using a helper column, but ran into issues trying to get it to return multiple values for same matched criteria. The yellow highlighted cells in Rows 2 and 3 on both spreads match each other exactly, but I need get the both of the different ID number results from column D.

    Dave, The second formula is working perfectly. I'm going to test it out on a full data set. Thank you!

    And just so I can understand better, can you please tell me what the ROW($A$2:$A$20)-MIN(ROW($A$2:$A$20))+1) parts of the formula do? I was confused on which spreadsheet/data set those were supposed to refer to; and it seems like I got the same result no matter what I changed them to.

    Thanks again guys.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Match multiple criteria and return multiple values.

    Quote Originally Posted by lodewyj View Post
    Hi guys,

    And just so I can understand better, can you please tell me what the ROW($A$2:$A$20)-MIN(ROW($A$2:$A$20))+1) parts of the formula do? I was confused on which spreadsheet/data set those were supposed to refer to; and it seems like I got the same result no matter what I changed them to.

    Thanks again guys.
    You are welcome. Thank you for the feedback.

    In resets the indexing numbers to start at 1 so that the formula can begin referencing the 1st row in the index range. I use this particular construction out of habit because I like to use named ranges. You will often see contributors use ROW($A$2:$A$20)-ROW($A$2))+1. They are fundamentally the same although the latter saves an additional function call.

    I was confused on which spreadsheet/data set those were supposed to refer to; and it seems like I got the same result no matter what I changed them to.
    Good observation. The sheet names are irrelevant here. ROW($A$2:$A$20) is ROW($A$2:$A$20) no matter the sheet reference.

    I have to agree with Richard for sure. Helpers simplify and often make resource hungry array formulas unnecessary. I didn't put my head to that approach however.

+ 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] Array formula to return list of values that match multiple criteria
    By TFiske in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-30-2016, 01:57 PM
  2. [SOLVED] Index/Match with Multiple Criteria and Multiple return values
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-28-2015, 10:27 AM
  3. [SOLVED] Return Multiple values from a column with index and match, and search criteria
    By marcusduton in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 02-15-2015, 09:59 PM
  4. Replies: 0
    Last Post: 07-08-2014, 09:51 AM
  5. Replies: 7
    Last Post: 08-04-2013, 03:41 PM
  6. [SOLVED] How to return multiple values that match a single search criteria?
    By JSallen in forum Excel General
    Replies: 4
    Last Post: 11-28-2012, 11:49 AM
  7. SOS:Return multiple values against multi criteria match and index function
    By nitesh_inin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-26-2012, 05:45 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