Excel Formulas to Find the Last Matching Value in a Column

📅 Jun 15, 2026 📝 Sarah Miller

Locating the absolute last entry in an Excel ledger is a common hurdle when managing dynamic financial logs. When tracking standard funding sources-such as venture capital, private equity, or traditional bank loans-standard VLOOKUP formulas fall short by only retrieving the first match. Utilizing a modern XLOOKUP or lookup vector formula grants immediate visibility into your final transaction state. Note the stipulation: your source column must be formatted consistently to prevent mismatch errors. For instance, when tracking "Series A" or "Federal Grant" disbursements, this technique ensures you capture the most recent record. Below, we outline the exact formulas and step-by-step logic to implement this solution.

Excel Formulas to Find the Last Matching Value in a Column

Introduction

By default, Excel's most popular lookup functions-such as VLOOKUP and standard MATCH-are designed to search from the top down. They stop searching the moment they find the first match, returning the corresponding value and leaving subsequent matches ignored.

However, in real-world data analysis, you often need to find the last occurrence of a value. Common scenarios include finding a customer's most recent purchase date, retrieving the latest update on a project task, or grabbing the final stock price from a historical ledger.

Fortunately, Excel offers several ways to search from the bottom up. Depending on your version of Excel, you can use the modern, straightforward XLOOKUP, the classic and highly compatible LOOKUP vector trick, or a dynamic array combination using FILTER and INDEX. In this comprehensive guide, we will explore each of these formulas, explain how they work under the hood, and help you choose the best method for your spreadsheet.


Method 1: The Modern Way – XLOOKUP (Excel 365 & Excel 2021+)

If you are using Microsoft 365 or Excel 2021 and newer, the easiest and most efficient way to find the last occurrence of a value is by using the XLOOKUP function. Unlike its predecessor VLOOKUP, XLOOKUP includes a dedicated argument that controls the search direction.

The XLOOKUP Syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

To search from the bottom of a list to the top (last to first), you simply need to set the sixth argument, [search_mode], to -1.

Step-by-Step Example

Imagine you have a sales log where products are listed as they are sold. You want to find the last sale amount for "Widget A".

Row Column A (Product) Column B (Sale Amount)
2 Widget A $120
3 Widget B $250
4 Widget A $150
5 Widget C $90
6 Widget A $180

To find the last sale amount for "Widget A" (which is $180 in row 6), use the following formula:

=XLOOKUP("Widget A", A2:A6, B2:B6, "Not Found", 0, -1)

How It Works:

  • "Widget A": The value you want to search for.
  • A2:A6: The array containing the product names.
  • B2:B6: The array containing the sale amounts you want to return.
  • "Not Found": The fallback text if the product is not in the list.
  • 0: Specifies an exact match (this is the default, but required if you want to access the next parameter).
  • -1: This is the magic parameter. It tells Excel to perform a reverse search, starting from row 6 and moving upward to row 2.

Method 2: The Classic Way – LOOKUP (All Excel Versions)

If you need your spreadsheet to be compatible with older versions of Excel (like Excel 2010, 2013, or 2016), XLOOKUP is not available. In this case, the classic LOOKUP vector trick is the gold standard.

The LOOKUP Formula

=LOOKUP(2, 1/(lookup_range=lookup_value), return_range)

Using our previous sales log table, the formula to find the last sale amount for "Widget A" is:

=LOOKUP(2, 1/(A2:A6="Widget A"), B2:B6)

How It Works (Under the Hood):

This formula seems counterintuitive at first glance. Why search for the number 2? Let's deconstruct the math step-by-step:

  1. Evaluation of the Criteria: (A2:A6="Widget A") compares every cell in range A2:A6 to "Widget A". This returns an array of Boolean values (TRUE or FALSE):
    {TRUE; FALSE; TRUE; FALSE; TRUE}
  2. The Division Operation: We then divide the number 1 by this array: 1 / {TRUE; FALSE; TRUE; FALSE; TRUE}. In Excel mathematical operations, TRUE is treated as 1, and FALSE is treated as 0.
    • 1 / TRUE becomes 1 / 1, which equals 1.
    • 1 / FALSE becomes 1 / 0, which results in a division-by-zero error (#DIV/0!).
    The resulting lookup array is:
    {1; #DIV/0!; 1; #DIV/0!; 1}
  3. The Binary Search Behavior: The LOOKUP function is designed to handle sorted data using binary search. If it cannot find the lookup value (which is 2), and the lookup value is larger than any value in the array (the maximum value in our array is 1), LOOKUP will do two things:
    • It completely ignores error values (like #DIV/0!).
    • It matches the last numeric value in the array that is less than or equal to the lookup value.
    The last numeric value (1) in our array corresponds to the last TRUE match, located in row 6.
  4. Returning the Result: Once it identifies the position of the last 1, it looks up the value in the corresponding position of the return range (B2:B6), which is $180.

Method 3: INDEX and MATCH (For Older Excel Versions / Array Formula)

Before dynamic arrays, power users often relied on an INDEX and MATCH combination. This method is highly transparent because it calculates the absolute row numbers of all matches, finds the maximum row number, and extracts the data from that row.

The INDEX/MATCH/MAX/ROW Formula

=INDEX(return_range, MATCH(MAX(IF(lookup_range=lookup_value, ROW(lookup_range))), ROW(lookup_range)))

Using our sales log sample, the formula is:

=INDEX(B2:B6, MATCH(MAX(IF(A2:A6="Widget A", ROW(A2:A6))), ROW(A2:A6)))

Note: If you are using Excel 2019 or older, you must press Ctrl + Shift + Enter to execute this as an array formula. If entered correctly, Excel will wrap the formula in curly braces { }.

How It Works:

  • IF(A2:A6="Widget A", ROW(A2:A6)) checks each cell in Column A. If it matches "Widget A", it returns its actual Excel row number; otherwise, it returns FALSE. This yields: {2; FALSE; 4; FALSE; 6}.
  • MAX(...) finds the highest row number from that array, which is 6.
  • MATCH(6, ROW(A2:A6)) translates that absolute spreadsheet row number into a relative index position inside our range (A2:A6). Since row 6 is the 5th element in our range, it returns 5.
  • INDEX(B2:B6, 5) grabs the 5th value in the return range, resulting in $180.

Method 4: The Dynamic Array Way – FILTER & INDEX (Excel 365)

For users who prefer highly readable formulas, the combination of FILTER and INDEX provides a modern alternative. This approach filters the data first, and then simply grabs the very last item from the filtered list.

The Formula

=LET(matches, FILTER(return_range, lookup_range=lookup_value), INDEX(matches, ROWS(matches)))

Let's apply this to our "Widget A" example:

=LET(matches, FILTER(B2:B6, A2:A6="Widget A"), INDEX(matches, ROWS(matches)))

How It Works:

  1. The LET function allows us to define a variable, which we call matches. This makes the formula cleaner and faster because Excel only has to compute the filter operation once.
  2. FILTER(B2:B6, A2:A6="Widget A") isolates only the sale amounts for "Widget A". It outputs a smaller array: {$120; $150; $180}.
  3. ROWS(matches) counts how many records made it through the filter. In this case, there are 3 records.
  4. INDEX(matches, 3) retrieves the 3rd (and final) item in our filtered list, which is $180.

Summary: Which Formula Should You Use?

To help you decide which formula is best suited for your specific workbook, consider this comparison table:

Method Excel Version Compatibility Complexity Performance (Large Datasets) Key Advantage
XLOOKUP Office 365 / Excel 2021+ Low Fast Easiest to write and maintain. No workarounds required.
LOOKUP (2, 1/...) All Versions (Excel 2003+) Medium Moderate to Fast Universal compatibility. No array entry (CSE) required.
INDEX / MATCH / MAX All Versions High Slow on massive sheets Transparent step-by-step logic utilizing native row numbers.
FILTER / INDEX Office 365 / Excel 2021+ Medium Fast Extremely flexible; easily handles multiple criteria conditions.

Pro-Tip: Handling Errors Gracefully

If your lookup value might not exist in the list, your formulas can return standard Excel errors (like #N/A). To prevent this and keep your spreadsheets polished, wrap your legacy formulas in IFERROR, or use XLOOKUP's native error handling:

  • With XLOOKUP: =XLOOKUP("Widget Z", A2:A6, B2:B6, "No Sales Found", 0, -1)
  • With LOOKUP: =IFERROR(LOOKUP(2, 1/(A2:A6="Widget Z"), B2:B6), "No Sales Found")

Conclusion

Finding the last occurrence of a value in a column is a standard data manipulation requirement. If you are on the latest versions of Excel, save time and prevent errors by using XLOOKUP with its search direction set to -1. If you are building spreadsheets that must work across your entire organization-including users on legacy versions of Excel-use the reliable LOOKUP(2, 1/(criteria), return_range) trick. Both approaches will ensure your data calculations remain accurate, robust, and dynamic.

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.