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

Data Analysis

  • How to Use Solver Tool in Excel
  • How To Perform and Interpret Regression Analysis in Excel
  • How to do a t-Test in Excel?
  • Excel Bar Chart
  • Conditional Formatting Data bars Examples in Excel

References

  • How to get address of named range in Excel
  • Get nth match with INDEX / MATCH in Excel
  • Multi-criteria lookup and transpose in Excel
  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions
  • INDEX function: Description, Usage, Syntax, Examples and Explanation

Data Validations

  • Excel Data validation unique values only
  • Excel Data validation specific characters only
  • How To Create Drop-down List in Excel
  • Excel Data validation allow weekday only
  • Excel Data validation require unique number

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.

Worked Example:   Get cell content at given row and column in Excel

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.

Worked Example:   Countif function in Excel

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”.

Worked Example:   How to get address of first cell in range in Excel

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

Previous Post:

Weighted average in Excel

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

  • IF with boolean logic in Excel
  • Nested IF function example in Excel
  • How to use Excel OR Function
  • Return blank if in Excel
  • TRUE function: Description, Usage, Syntax, Examples and Explanation

Date Time

  • Get first day of previous month in Excel
  • Steps to create Dynamic calendar grid in Excel
  • Get project end date in Excel
  • DATE function: Description, Usage, Syntax, Examples and Explanation
  • Get last working day in month in Excel

Grouping

  • Map text to numbers in Excel
  • Group times into 3 hour buckets in Excel
  • Running count group by n size in Excel
  • Group times into unequal buckets in Excel
  • Map inputs to arbitrary values in Excel

General

  • How to calculate decrease by percentage in Excel
  • Basic text sort formula in Excel
  • Excel Operators
  • Check if range contains a value not in another range in Excel
  • Basic numeric sort formula in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning