Excel has no built-in "search from right" command, but you can get that result with a formula. The standard way is to combine XLOOKUP with search_mode -1, which scans from the last item back to the first, so it returns the rightmost match instead of the leftmost one. If your workbook is on an older version without XLOOKUP, you can use the LOOKUP trick with a deliberately impossible comparison to find the last matching value. Either approach reads the range right to left and returns the correct row, column, or position.

This guide covers both formulas, explains what each one really does, and notes the mistakes that make people think Excel cannot search backwards. The exact function names and arguments below are standard Excel behaviour; Excel on the web and recent desktop versions support XLOOKUP, while older desktop releases may only offer the fallback method.

What You'll Need

  • A version of Excel that supports XLOOKUP, or willingness to use the LOOKUP fallback on older versions.
  • Your data arranged in a clean range or an Excel Table, with no stray blank rows inside it.
  • An empty cell for the formula result, ideally away from the source data so you do not accidentally overwrite anything.
  • A clear idea of whether you want the last value, the last position, or the last partial match from the right, since each needs a slightly different formula.

Step-by-Step

Method 1: XLOOKUP with search_mode -1

  1. Click the cell where the result should appear and type an equals sign to begin a formula.
  2. Type XLOOKUP( to start the function. Excel will show argument hints as you build it.
  3. For the first argument, the lookup value, select or type what you are searching for, for example a name, an order number, or a reference in another cell such as A2.
  4. For the lookup array, select the column you want Excel to scan. Press Enter after selecting so the reference is entered, and press F4 once or twice to lock it as absolute (for example $B$2:$B$100) if you plan to copy the formula down.
  5. For the return array, select the column or row containing the answer you want back. This does not have to be next to the lookup column; XLOOKUP does not care about position.
  6. Skip the optional fourth argument (if_not_found) or enter a friendly fallback such as "Not found" in quotes so a missing match returns a readable message instead of an error.
  7. For the fifth argument, the search mode, type -1. This is the key step: it tells Excel to search from last to first, so the rightmost matching entry wins.
  8. Close the bracket and press Enter. Check the returned value against your data by scrolling to the bottom of the range and confirming the match that appears last is the one shown.

A complete example for a two-column lookup, where names are in B and scores in C and you want the last score recorded for the name in E2:

=XLOOKUP(E2,$B$2:$B$100,$C$2:$C$100,"Not found",-1)

In plain words: look up E2 in the name list, return the matching score, give up gracefully if there is no match, and start looking from the bottom of the list. Change -1 to 1 and the same formula returns the first score instead, which is the quickest way to prove to yourself that the search direction is what changed.

Method 2: Last-match lookup on older Excel versions

  1. Select the result cell and confirm your lookup column and return column are both the same height, since this formula compares them row by row.
  2. Enter this pattern: =LOOKUP(2,1/($B$2:$B$100=E2),$C$2:$C$100)
  3. Press Enter. The odd-looking 1/(...=E2) part turns every matching row into 1 and every non-matching row into a divide-by-zero error. LOOKUP then finds the last numeric value it can, which is the last 1 in the list, and returns the matching item from the results column.
  4. If the formula returns #N/A, there is genuinely no match, because every row in the test column produced an error. Check spelling and stray spaces in the lookup cell.
  5. Copy the formula down only after locking the ranges with dollar signs; otherwise the ranges shift and start pointing at the wrong rows.

Method 3: Find the rightmost position of a text match

Sometimes you do not want a value but the position of the last match inside a single cell, for example the last slash in a file path. There is no direct function for this, so build it with SEARCH and SUBSTITUTE:

  1. Count how many times the character appears: =LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))
  2. Swap the last occurrence for a unique marker: =SUBSTITUTE(A2,"/","|",LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))) replaces only the final slash because the instance number equals the total count.
  3. Find the marker's position with SEARCH("|", ...), or pull everything after it with RIGHT and LEN. This scans effectively from the right because only the last instance is changed.

Common Mistakes

  • Forgetting search_mode entirely. Leave out the fifth argument and XLOOKUP defaults to a forward search, silently returning the first match. If you are comparing results and they "look wrong", check this argument first.
  • Using -1 with an unsorted range in MATCH. MATCH with -1 only works correctly on data sorted descending, and returns wrong results otherwise. XLOOKUP's -1 does not need sorting, which is why it is the better tool.
  • Unequal range sizes. The lookup array and return array in XLOOKUP must be the same number of rows (or columns). A mismatch produces a #VALUE! error.
  • Trailing spaces or text-formatted numbers. "Smith" and "Smith " are different values. Clean with TRIM, or convert numbers stored as text before matching.
  • Locking the wrong cells. Copying a formula with relative references drifts down the sheet. Use F4 to make ranges absolute.
  • Expecting -1 to search left within a row automatically. The direction applies to the arrays you supply. If you want right-to-left across columns, pass a horizontal range or build the return columns accordingly.

Tips

  • Add FALSE as the sixth XLOOKUP argument (match_mode 0) for exact matches only, and use 2 for wildcard support.
  • Wrap the whole formula in IFERROR only if you prefer a custom message; XLOOKUP's if_not_found argument is cleaner and keeps the formula shorter.
  • Convert your range to a Table with Ctrl+T so ranges grow automatically as new rows are added, and you can use structured references such as instead of fixed ranges.
  • Test the direction by temporarily adding a duplicate entry at the top and bottom of the data with different values, then confirm which one the formula returns.
  • For the last date, last stock count, or most recent price, searching from the right is usually the correct business answer, because the newest entry is often at the bottom of the sheet.
  • Use the Evaluate Formula tool on the Formulas tab to step through the formula and see exactly which match is being selected.

Troubleshooting

  • #NAME? error: your Excel version does not recognise XLOOKUP. Either update, use Excel on the web, or switch to the LOOKUP fallback method.
  • Returns the first match instead of the last: the search_mode argument is missing or set to 1. Re-open the formula and check the fifth argument after the return array and the if_not_found value.
  • #VALUE! error: the lookup and return arrays have different dimensions. Resize them so both cover the same rows.
  • #N/A even though the value is visible: check for trailing spaces with TRIM, text versus number formatting with the cell's format, and non-printing characters. Copying the lookup cell directly from the source is a fast test.
  • Wrong result after copying down: references were not locked. Replace the ranges with absolute references and copy again.
  • Formula works in one cell but breaks in another: check that the ranges still point to the correct sheet, especially after rows were inserted or deleted above the data.

Frequently Asked Questions

Does XLOOKUP search from the right by default?

No. It searches from the top or start of the array unless you pass -1 as search_mode.

Can I search from right to left across columns instead of rows?

Yes. Supply horizontal ranges, or combine XLOOKUP with the right return array, and search_mode -1 applies to that orientation.

What does search_mode 2 do?

It performs a binary search, which is faster on very large sorted data but requires correct sorting and can return incorrect results on unsorted data.

Is there a right-to-left option in the Find dialog?

No. The Find and Replace dialog searches in the normal reading direction and has no direction toggle for scanning backwards.

Why does LOOKUP(2,1/(...)) work?

LOOKUP ignores error values and finds the last numeric value it can, and the division trick converts only matching rows to numbers, so the final match is returned.

Will this work with partial text matches?

Yes, with XLOOKUP set match_mode to 2 for wildcards, then use search_mode -1 to get the last wildcard match from the right.