Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Conditional Formatting Rules in Excel
  • Filter Data Based on Date in Excel
  • How To Sort One Column or Multiple Columns in Excel
  • Conflicting Multiple Conditional Formatting Rules in Excel
  • Understanding Pivot Tables in Excel

References

  • Two-way lookup with VLOOKUP in Excel
  • Count rows that contain specific values in Excel
  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions
  • How to use Excel ROWS Function
  • VLOOKUP function: Description, Usage, Syntax, Examples and Explanation

Data Validations

  • Excel Data validation allow weekday only
  • Excel Data validation only dates between
  • Excel Data validation allow uppercase only
  • How To Create Drop-down List in Excel
  • Excel Data validation number multiple 100

Extract all partial matches in Excel

by

This tutorial shows how to Extract all partial matches in Excel using the example below;

Formula

=IF(F5>ct,"",INDEX(data,AGGREGATE(15,6,(ROW(data)-ROW($B$5)+1)/ISNUMBER(SEARCH(search,data)),F5)))

Explanation

To extract all matches based on a partial match, you can use use an array formula based on the INDEX and AGGREGATE functions, with support from ISNUMBER and SEARCH. In the example shown, the formula in G5 is:

=IF(F5>ct,"",INDEX(data,AGGREGATE(15,6,(ROW(data)-ROW($B$5)+1)/ISNUMBER(SEARCH(search,data)),F5)))

with the following named ranges: “search” = D5, “ct” = D8, “data” = B5:B55.

Note: this is an array formula, but it does not require control + shift + enter, since AGGREGATE can handle arrays natively.

How this formula works

The core of this formula is the INDEX function, with AGGREGATE used to figure out the “nth match” for each row in the extract area:

INDEX(data,nth_match_formula)

Almost all of the work is in figuring out and reporting which rows in “data” match the search string, and reporting the position of for each matching value to INDEX. This is done with the AGGREGATE function configured like this:

AGGREGATE(15,6,(ROW(data)-ROW($B$5)+1)/ISNUMBER(SEARCH(search,data)),F5)

The first argument, 15, tells AGGREGATE to behave like SMALL, and return nth smallest values. The second argument, 6, is an option to ignore errors. The third argument is an expression that generates an array of matching results (described below). The forth argument, F5, acts like “k” in SMALL to specify the “nth” value.

AGGREGATE operates on arrays, and the expression below builds an array for the third argument inside AGGREGATE :

(ROW(data)-ROW($B$5)+1)/ISNUMBER(SEARCH(search,data))

Here, the ROW function is used to generate an array of relative row numbers, and ISNUMBER and SEARCH are used together to match the search string against values in the data, which generates an array of TRUE and FALSE values.

The clever bit is to divide the row numbers by the search results. In a math operation like this, TRUE behaves like 1, and FALSE behaves like zero. The result is row numbers associated with a positive match are divided by 1 and survive the operation, while row numbers associated with non-matching values are destroyed and become #DIV/0 errors. Because AGGREGATE is set to ignore errors, it ignores the #DIV/0 errors, and returns the “nth” smallest number in the remaining values, using the number in column F for “nth”.

Managing performance

Like all array formulas, this formula is “expensive” in terms of resources with a large data set. To minimize performance impacts, the entire INDEX and MATCH formula is wrapped in IF like this:

=IF(F5>ct,"",formula)

where the named range “ct” (D8) holds this formula:

=COUNTIF(data,"*"&search&"*")

This check stops the the INDEX and AGGREGATE part of the formula from running once all matching values have been extracted.

Array formula with SMALL

If your version of Excel does not have the AGGREGATE function, you can use an alternative formula based on SMALL and IF:

=IF(F5>ct,"",INDEX(data,SMALL(IF(ISNUMBER(SEARCH(search,data)),ROW(data)-ROW($B$5)+1),F5)))

Note: this is an array formula and must be entered with control + shift + enter.

Post navigation

Next Post:

Win loss points calculation in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • How to use Excel AND Function
  • How to return blank in place of #DIV/0! error in Excel
  • Invoice status with nested if in Excel
  • IF function: Description, Usage, Syntax, Examples and Explanation
  • SWITCH function example in Excel

Date Time

  • Calculate date overlap in days in Excel
  • List holidays between two dates in Excel
  • EOMONTH function: Description, Usage, Syntax, Examples and Explanation
  • Convert decimal hours to Excel time
  • Count dates in current month in Excel

Grouping

  • How to randomly assign people to groups in Excel
  • Group numbers with VLOOKUP in Excel
  • Categorize text with keywords in Excel
  • Group times into 3 hour buckets in Excel
  • Group times into unequal buckets in Excel

General

  • How to calculate percentage discount in Excel
  • How to generate random times at specific intervals in Excel
  • AutoFit Column Width, AutoFit Row Height in Excel
  • How to fill cell ranges with random text values in Excel
  • How to add sequential row numbers to a set of data in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning