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

Data Analysis

  • Subtotal function in Excel
  • How to Create One and Two Variable Data Tables in Excel
  • How to Use Solver Tool in Excel
  • How To Remove Duplicates In Excel Column Or Row?
  • How To Sort One Column or Multiple Columns in Excel

References

  • Two-way lookup with VLOOKUP in Excel
  • How to get last row in numeric data in Excel
  • Count rows with at least n matching values
  • How to use Excel COLUMN Function
  • How to create dynamic named range with OFFSET in Excel

Data Validations

  • Excel Data validation must contain specific text
  • Excel Data validation don’t exceed total
  • Excel Data validation must not contain
  • Excel Data validation allow uppercase only
  • Excel Data validation allow weekday only

Get nth match in Excel

by

This tutorial shows how to Get nth match in Excel  using the example below;

Formula

=SMALL(IF(logical,ROW(list)-MIN(ROW(list))+1),n)

Explanation

To get the position of the nth match (for example, the 2nd matching value, the 3rd matching value, etc.), you can use a formula based on the SMALL function. In the example shown, the formula in G5 is:

=SMALL(IF(list=E5,ROW(list)-MIN(ROW(list))+1),F5)

This formula returns the position of the second occurrence of “red” in the list.

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

Worked Example:   Minimum value in Excel

How this formula works

This formula uses the named range “list” which is the range B5:B11.

The core of this formula is the SMALL function, which simply returns the nth smallest value in a list of values that correspond to row numbers. The row numbers have been “filtered” by the IF statement, which applies the logic for a match. Working from the inside out, IF compares all values in the named range “list” to the value in B5, which creates an array like this:

{TRUE;FALSE;FALSE;FALSE;TRUE;FALSE;TRUE}

The “value if true” is a set of relative row numbers created by this code:

ROW(list)-MIN(ROW(list))+1

The result is an array like this:

{1;2;3;4;5;6;7}

See this page for a full explanation.

Worked Example:   Extract all partial matches in Excel

With a logical test that returns an array of results, the IF function acts as a filter – only row numbers that correspond to a match survive, the rest return FALSE. The result returned by IF looks like this:

{1;FALSE;FALSE;FALSE;5;FALSE;7}

The numbers 1, 5, and 7 correspond to the location of “red” in the list.

Worked Example:   Minimum value if in Excel

Finally, SMALL returns the nth smallest item in this list, ignoring FALSE values. In the example, F5 contains 2, so SMALL returns the 2nd smallest value: 5.

Combine with INDEX

Once you have the relative position of the nth match, you can use that position inside of INDEX to return an associated value.

Post navigation

Previous Post:

Get location of value in 2D array in Excel

Next Post:

Get nth match with VLOOKUP 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

  • SWITCH function: Description, Usage, Syntax, Examples and Explanation
  • TRUE function: Description, Usage, Syntax, Examples and Explanation
  • OR function: Description, Usage, Syntax, Examples and Explanation
  • How to use IFS function in Excel
  • IF with wildcards in Excel

Date Time

  • How to show last updated date stamp in Excel
  • DATEVALUE function: Description, Usage, Syntax, Examples and Explanation
  • Add workdays no weekends in Excel
  • How to get Holiday Date from Year in Excel
  • Series of dates by day

Grouping

  • Running count group by n size in Excel
  • Group times into 3 hour buckets in Excel
  • Categorize text with keywords in Excel
  • Group numbers with VLOOKUP in Excel
  • Group times into unequal buckets in Excel

General

  • Common Errors in Excel
  • AutoRecover file that was never saved in Excel
  • Basic text sort formula in Excel
  • Find, Select, Replace and Go To Special in Excel
  • Subtotal by color in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning