+ Reply to Thread
Results 1 to 20 of 20

Multiple matches in one row (no array formula)

  1. #1
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Multiple matches in one row (no array formula)

    So I am capable of doing multiple matches without an array, utilizing a helper column, but I am having trouble coming up with a way to do them in one column via a formula.

    Basically, I am utilizing a countif to determine which match number the stuff is in the helper column, then utilizing either rows() or columns() to get that match number depending on which way I am dragging.

    I am sort of stuck on how I'd list multiple criteria at once in a single column utilizing a single formula though (i'm thinking along the lines of offsetting it by largest match number, but I don't know how I'd do that for a varying amount of criteria).

    Basically, instead of a table format, I'd want it to give all matches of the first criteria, followed by the next, etc. until all matches are found, then return errors if formula is still dragged down. The big challenge is I want to do this without an array formula if possible. I don't mind volatile functions as much, but would like to avoid them too if possible. Helper columns are totally okay too.

    Example attached.
    Attached Files Attached Files
    Last edited by TheN; 10-12-2016 at 04:59 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    While I take a look at this, may I enquire what your aversion is to array formulae??
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    On extremely large data sets they can quickly eat up resources. Most things I'd use this for have datasets of 30,000+ lines and hundreds of inputs.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    Not sure if this'll be much quicker....

    =IFERROR(INDEX($B:$B,SMALL(INDEX(($A$2:$A$8<>$F2)*10^10+ROW($A$2:$A$8),0),COLUMNS($G2:G2))),"")

    Copy across and down from G2.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    Oh, I think you misunderstood my expected outcome.

    I was looking for one of the two results on the 2nd tab marked "Desired" where all results are listed in a single column instead of a table format.

    Kudos for accomplishing my formula without a helper column though, pretty impressive (I don't quite understand it unfortunately, so I'll be unable to tweak it to work for the desired results).

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Multiple matches in one row (no array formula)

    Actually the practice of inserting one or more INDEX functions into a construction for the sole purpose of avoiding CSE (CTRL+SHIFT+ENTER) renders the resulting construction less efficient than the equivalent CSE version. It is an extra function call, after all.

    More importantly, required keystroke combination aside, the non-CSE INDEX version is no less of an 'array formula' than the non-INDEX CSE one.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    So, anyone have any ideas?

    every time I think I've got it, it ends up being an array formula

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    How many categories of animal are there in your real data?

  9. #9
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    that was just an example, but there is 10+ categories with matches numbering about 50+ in 15,000+ lines for the smallest sample size.

    It is possible to do with array formulas, but If I want to do the match more than once (for example retrieve the genus and species in my example of animals) it quickly slows down the sheet and makes it very large very quickly.

    It also has issues if I plan to make it a shared workbook, due to the nature of array formulas.

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Multiple matches in one row (no array formula)

    In this case, a single-formula set-up simply cannot be achieved without resource to a formula which processes all items within the arrays passed.

    Regards

  11. #11
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Multiple matches in one row (no array formula)

    Or try this ...

    =IFERROR(INDEX($B:$B,AGGREGATE(15,6,ROW($A$2:$A$8)/($A$2:$A$8=$F2),COLUMNS($G2:G2))),"")

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Multiple matches in one row (no array formula)

    Just because it does not required CSE, AGGREGATE is no less an 'array formula'. The same applies to SUMPRODUCT. And others.

    Regards

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    Any array/non-array formulae that spring to mind would simply not be practical for that number of categories.

    I know little or nothibg about VBA, but it's probably your only practical way forward.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    I suppose it would not be acceptable to copy/paste you helper column to another sheet, sort it alphabetically (you may need to change the number format to show 3 digits - 001, 002, etc) and then do a simple lookup....

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,196

    Re: Multiple matches in one row (no array formula)

    Sample VBA code to give "Option 2" results

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    Quote Originally Posted by Glenn Kennedy View Post
    I suppose it would not be acceptable to copy/paste you helper column to another sheet, sort it alphabetically (you may need to change the number format to show 3 digits - 001, 002, etc) and then do a simple lookup....
    It could be, since I can think of ways to do that with formulas/named ranges (and manually doing it isn't much of a hassle if it speeds my sheet up that much). You definitely have my attention. How would that help to solve this?

    I've copy pasted helper columns as values before so I could do sorts, so this wouldn't be much of a stretch from that.

    @johntopley
    Thank you for the VBA code, but I would still like to be able to do it with a regular formula if possible. That can definitely work as a backup plan, thank you.

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    Try this out... there's only one AF-word (array formula) in it. It calculated 5,000 rows in less than 3 seconds... I took you very much at your word when you said that you don't mind helpers... If you can tolerate (another) AF-word formula, you could get it to list your unique categories in alphabetical order. I did it manually here (there were only 3; so it wasn't a huge strain).

    The key formula is the Array formula which repeats the category names by the appropriate amount:

    =IFERROR(INDEX($F$2:$F$4,MATCH(0,--(COUNTIF($I$1:I1,$F$2:$F$4)=$G$2:$G$4),0)),"")
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    I like it, I can create the helper with an array formula (which doesn't need to be dragged superfluously) then copy paste it as values, and eliminate the strain after the initial calculations.

    That should suffice I think, probably the best I am going to get.

    Thank you very much.

  19. #19
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Multiple matches in one row (no array formula)

    Great! I'm glad to have helped! If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  20. #20
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: Multiple matches in one row (no array formula)

    yup had to find someone else to give rep to before I could re-rep you. Haha

    Solved now.

+ 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. Replies: 3
    Last Post: 05-25-2016, 11:36 AM
  2. Replies: 3
    Last Post: 05-25-2016, 11:34 AM
  3. Replies: 2
    Last Post: 05-25-2016, 11:32 AM
  4. [SOLVED] INDEX MATCH array formula that matches substring n gives multiple matches
    By bkwins in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-12-2013, 04:57 AM
  5. Replies: 7
    Last Post: 04-11-2013, 12:46 AM
  6. [SOLVED] two-array matching formula with multiple matches
    By ilikeexcel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-09-2013, 02:19 PM
  7. Replies: 6
    Last Post: 05-26-2012, 04:56 AM

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