+ Reply to Thread
Results 1 to 20 of 20

How to match multiple criteria from a list to pull entire row from another worksheet?

  1. #1
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Question How to match multiple criteria from a list to pull entire row from another worksheet?

    Good day all,

    I am working on trying to be able to pull data that matches criteria in 1 worksheet that would return an entire row of data from another worksheet and place the data on the 3rd sheet.

    The data I wish to match has 3 columns (First Name, Last Name, Year)

    The data I pulling from has Columns A through AI and I am trying to match against first name, last name and year.

    In the data set, I wish to return all lines of data that match the first name, last name match and is equal to or greater than the year.

    I have tried VLOOKUP but my understanding is that you cannot use multiple match criteria for that.

    I tried using Index(range,Match(),0) and I thought if I have the column value a zero value it would return the entire row of date I consistently could only get it to return one cell's value.

    I have not tried any of this with a macro or VB coding, but I am not opposed to that if someone wishes to point me in the proper direction.

    I have attached a sample spreadsheet that has raw data on tab 1, match criteria on tab 2 and the hopeful result set on tab 3.

    Thank you in advance for taking the time to read this and any help that is offered.
    Attached Files Attached Files

  2. #2
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Ozymandius welcome to the forum.

    In the attached find two helper columns in 'Match Data'. These establish the lower and upper boundary row number for each individual and years >= YEAR.

    In D2 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In E2 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then there is a duplicate Result sheet 'Result Set (2)'. Find a helper column A inserted to the left. It has an array formula that returns each relevant row number from 'Raw Data'. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter. Fill down until you get blanks.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then in B2 filled down and across until you get blanks. This is also array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 06-15-2017 at 08:02 PM. Reason: additional info and welcome
    Dave

  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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Removed by FR.
    Last edited by FlameRetired; 06-15-2017 at 08:02 PM.

  4. #4
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    FlameRetired,

    I just wanted to thank you very much. I am still trying to understand exactly how this is working and how to expand it to a much larger section of raw data, but while I am working through understanding this I wanted to make sure I thanked you for this. If you do not mind I would like to be able to post back on this thread with future questions.

    Brian

  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: How to match multiple criteria from a list to pull entire row from another worksheet?

    You are welcome, and yes of course. I am still subscribed. I'll stay alert. But one thing.
    I am still trying to understand exactly how this is working and how to expand it to a much larger section of raw data,
    While I have not found a formula work around for those array formulas you need to know that they are resource hungry. Too many of them will slow a work book down. Let us know if that becomes unacceptable.

  6. #6
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Brian if you're still with us I found an non array formula for the last set. In B2 of 'Result Set (2)' fill down and across until you get blanks.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I'm still working on the helper in 'Result Set (2)'. It may not be much of a problem as it is only one column, but let me know.

  7. #7
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    Dave,

    I am definitely still here and I have to say I am definitely seeing the performance issues you were referring to. My original data set goes from A1:AI13129 so the arrays are definitely an issue. I am still trying to make sure I understand the Transpose and why you are doing the "1/(($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=$C2))" as the first part of the INDEX. I am going to try your non array formula and see how that goes and thank you again!

  8. #8
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    I am still trying to make sure I understand the Transpose
    Try Googling the term "orthogonal".

    Transposing makes certain that each element in D2:D6 and E2:E6 (which recall are row numbers returned by the previous helper formulas) are compared with all the row numbers in 'Raw Data'. To do so requires one of the ranges be "cross-ways" ... arranged as a single row to the other which is a single column ... orthogonal. That is an indirect way to assign indexing numbers to qualifying combinations of first name, last name, years. It's a lot of trouble to go to to get index numbers, but I can't think of another formula way to do it.

    Having said that:
    My original data set goes from A1:AI13129
    And Yikes! That is huge! I am going to see if I can get us some help. Someone with VBA skills make be able to help you out.

    You didn't ask, but did you want a "walk-through" on the "1/(($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=$C2))" part? Let me know after I get some help for the other part. The explanation is a bit involved.

  9. #9
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Double posted.
    Last edited by FlameRetired; 06-15-2017 at 11:52 PM.

  10. #10
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    Ok, so the Transpose are just like a transpose of any matrix. I have not messed with those since linear algebra a long time ago and certainly never in excel! An explanation of that other part would be great if you are willing. I love learning new things things in excel! Thanks!

  11. #11
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    I'll do my best.

    In the FORMULAS menu locate the Evaluate Formula feature. It will help. Together with that and the F9 function key you can dissect and trouble shoot formulas. They are excellent tools for self instruction as well. I recommend them whenever I can.

    That said this needs some context.

    =MATCH(1,INDEX(1/(($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=C2)),0),0)

    With D2 in 'Match Data' active click on Evaluate Formula. Click Evaluate repeatedly and you will see how Excel calculates the formula step by step in context. Unfortunately the view port is quite small, but you can still get an idea especially when used in conjunction with the F9 function key.

    To use the F9 function key we start with operations in the inner most parentheses and work our way out ... just like algebra.

    To use the F9 function key start by selecting just ($A2='Raw Data'!$A$2:$A$373) in the formula bar. Press F9. You will see an array for TRUE / FALSE. Sometimes ($A2='Raw Data'!$A$2:$A$373) is TRUE sometimes it's FALSE. BTW the ";" are understood to be row separators in an array.

    Extend the selection in the formula bar to include ($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=C2) and hit the F9 function key again. You will see an array of 1s and 0s. This is the effect operators (multiplication in this case) have on TRUE/FALSE. They coerce TRUE and FALSE into their underlying numeric values 1 and 0.

    Now extend the selection in the formula bar to include 1/(($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=C2)). Hit F9. You will see an array of #DIV/0! errors and if you scroll up the array you will eventually see some 1s. MATCH will ignore errors in its second argument and will match the 1 (MATCH(1,1/array,0)) to the first 1 it finds in the array because the match type is set to 0 ... exact match. It returns the row number of that match.

    The INDEX function I've wrapped around the array is optional. In this case it removes the necessity of entering the formula with Ctrl + Shift + Enter. Just Enter works. It is still an array formula though.

    In the case of D2 the match is row 25.

    Now make E2 the active cell. This is the formula.

    =MATCH(2,INDEX(1/(($A2='Raw Data'!$A$2:$A$373)*($B2='Raw Data'!$B$2:$B$373)*('Raw Data'!$C$2:$C$373>=$C2)),0),1)

    The F9 steps are exactly the same and the array returned is exactly the same as in the previous. The difference here is that we are going to match 2 or at least a number greater than 1 to the same array but with a match type of 1 ... approximate match. MATCH will find the last number in the array less than or equal to 2. It returns that row number which in this case is 29.

    So Tommie Aaron Year>=1963 starts in row 25 and ends in row 29 of 'Raw Data'!A2:C373. (A2 is the first row.)

    Did this help?
    Last edited by FlameRetired; 06-16-2017 at 01:05 AM.

  12. #12
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    I have a new approach.

    This has just one non array helper column. As long as the years in 'Match Data' are in ascending order or all the same year this should work.

    In the new column A of 'Raw Data' this formula filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It's involved. I had to do some fiddling around with different functions and function combinations to get it to work, but it seems to.

    Then in D2 of 'Result Set (2)' filled down and across.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Let me know how it does.
    Last edited by FlameRetired; 06-16-2017 at 03:17 AM.

  13. #13
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    Thanks! I will be able to look at all of this later this evening. I really do appreciate the time taken and the patience shown in explanations!

  14. #14
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    Great hint of using evaluate formula and very nice and easy to follow explanation of the formula!

    The new method works wonderfully! I was able to expand it to the large data set and I see no major performance issues. Actually, the only issue I do see is from where I have kept the original method because it summing up the difference of the min and max rows and adding 1 to each line (or doing a count) gives me how many rows should be returned and I can use that to double check when I have spelling errors between the raw data and the match data.

    I am still working on understanding the MMULT function but that is more of a refresher on linear algebra again and not excel. It has been a while since I took the product of 2 matrices. ROW, ISNUMBER, EXACT, IFERROR and MATCH I have used before, though not much for ROW.

    Thank you again and do I need to do something to mark this thread as solved?

  15. #15
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Glad to hear it. Have you tested years in 'Match Data'? I am kind of curious.

    And yes. If you are satisfied it's solved select Thread Tools from the menu link above and mark thread as SOLVED.

    Have good weekend.

  16. #16
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    I actually had not tested that until you asked, but I changed one of the values in the Match Data to be 1964 instead of 1963 and I am not sure I got the results I expected.
    I then realized well from the data set that particular person had no data for years 1964, 1965, 1966 and 1967 so I changed the next one and also did not get results I expected.
    I used the Evaluate formula and the Match of D40 on Raw Data (Hitters) and it returns 200 which seemed odd to me. I have attached the larger worksheet in case you wish to analyze.
    What you have done works well for me and when I have to change the match data it will all have a new year (and the same year) so I think for my purposes this would work,
    but I also know when I am working on things like this I do not like the answer to be less than elegant when it comes to things like this so in case you feel the same way...

    Edit: I am having issues trying to attach a new file. it keeps failing.
    Attached Files Attached Files
    Last edited by Ozymandius; 06-16-2017 at 10:33 PM. Reason: Trying to add Attachment

  17. #17
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    Finally got it posted. I trimmed off a ton of data to get it under 1 MB

  18. #18
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    Yes. I got to thinking about that. Came back tonight another approach. I tested it on the original file. It works. I also found a way to streamline the helper and final formulas. It reduces a lot of repeating calculations.

    Find a new column A in both 'Raw Data' and 'Result Set (2)'. Just use fill series. I "future proofed" both sheets.(1000 rows)

    Then the indexing helper in column B 'Raw Data' is
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The indexing helper column B in 'Result Set (2)' is
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The final formula is now
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    They all calculate faster now. Try them and let me know what you think.

  19. #19
    Registered User
    Join Date
    06-15-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    9

    Re: How to match multiple criteria from a list to pull entire row from another worksheet?

    These is MUCH better for performance on the large data set! Thank you very much and is easy to follow as well! I have to remember the idea to add indexes to both original data set and result set! Thank you again!

  20. #20
    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: How to match multiple criteria from a list to pull entire row from another worksheet?

    You are welcome.

+ 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] Looking for help on unique value pull with multiple criteria using Index Match
    By shinobi2u in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-09-2017, 05:07 PM
  2. [SOLVED] Pull whole rows of data to another sheet that match any of multiple criteria
    By christechgeek in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-12-2015, 03:51 AM
  3. Issue using Index/Match to pull multiple occurrences of "Match" criteria
    By aridfriedman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-09-2014, 11:38 AM
  4. Replies: 10
    Last Post: 12-18-2012, 07:59 AM
  5. Replies: 2
    Last Post: 07-25-2012, 04:15 PM
  6. Pull from list based on multiple criteria
    By chitownsox14 in forum Excel General
    Replies: 3
    Last Post: 04-20-2011, 12:12 PM
  7. Replies: 5
    Last Post: 01-05-2011, 03:13 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