Excel Index Match - Partial strings with Multiple Results

后端 未结 2 1602
有刺的猬
有刺的猬 2021-01-15 06:13

I\'m trying to tweak this piece of code I found in a sample spreadsheet online but I can\'t quite get my head around it.

The original spreadsheet basically does an I

相关标签:
2条回答
  • 2021-01-15 06:19

    Building on Barry's code a little, I needed to make a few tweaks for my own use (current project I have at work).

    Tweaks I made:

    1. Returning the cell that matches my search criteria in my index
    2. Making the cell draggable in two dimensions so I could index multiple columns for specific information
    3. Making the "nth" counter vertical instead of horizontal (as my application is a database of sorts, and each column is a separate entry. At the top of each column is 5 rows populated based on the search term [in my case, the store number])

    The final result is:

    =IFERROR(INDEX(A$8:A$295,SMALL(IF(ISNUMBER(SEARCH('Store History'!$F$2,A$8:A$295)),ROW(A$8:A$295)-ROW(A$8)+1),ROWS(A$2:A2))),"")

    It is worth repeating that this is an array formula and needs to be entered using CTRL+SHIFT+ENTER

    This is placed in cell A2 and is dragged both vertically and horizontally (horizontally in my case is ever expanding as I add more entries into my database).

    My purpose for adding this comment (even though it is a long inactive thread) is to try and make this a more relevant search result on Google for "excel index match partial strings with multiple results" or variations of that. It took me hours of searching to find this solution, and it is extremely functional and elegant. My thanks to the OP and especially to Barry for his code!!

    0 讨论(0)
  • 2021-01-15 06:25

    Assuming by "partial match" you mean text that starts with the value in L1 then use this formula in N1

    =IFERROR(INDEX($I$2:$I$8,SMALL(IF(LEFT($H$2:$H$8,LEN($L$1))=$L$1,ROW($I$2:$I$8)-ROW($I$2)+1),COLUMNS($N1:N1))),"")

    confirm with CTRL+SHIFT+ENTER and copy across

    For a match anywhere in the text you can use this version

    =IFERROR(INDEX($I$2:$I$8,SMALL(IF(ISNUMBER(SEARCH($L$1,$H$2:$H$8)),ROW($I$2:$I$8)-ROW($I$2)+1),COLUMNS($N1:N1))),"")

    Neither formula is case-sensitive, although you can easily make the latter so by changing SEARCH to FIND

    Use of IFERROR function means you don't need repetition for error handling - needs Excel 2007 or later version

    0 讨论(0)
提交回复
热议问题