ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Lookups
  3. Find the Closest Match in Excel

Find the Closest Match in Excel

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

To find the closest match in Excel, measure how far each value is from your target with ABS, then look up the smallest gap: =XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),A2:A8). This works on unsorted data in Excel 2021 or Microsoft 365. If you only want the next smaller or next larger value, use XLOOKUP's match_mode -1 or 1 instead.

Key takeaways

  • The closest value is the one with the smallest gap, and ABS(B2:B8-E1) gives every gap as a positive number.
  • XLOOKUP(MIN(gaps), gaps, results) returns the item with the smallest gap, on unsorted data.
  • Next smaller (-1) and next larger (1) are not the same as closest: the nearest value can be on either side.
  • In Excel 2019 and earlier, use INDEX and MATCH with ABS, entered with Ctrl+Shift+Enter.
  • When two values are equally close, the formula returns the first one in the list.
On this page+
  1. The sample data
  2. How to find the closest match with XLOOKUP and ABS
  3. Closest vs next smaller vs next larger
  4. How to find the closest match in older Excel with INDEX and MATCH
  5. Next smaller or larger with MATCH on sorted data
  6. What happens with ties, blanks and text
  7. Return more than one column or the gap itself
  8. Practise it

To find the closest match in Excel, work out how far every value is from your target, then look up the one with the smallest gap. With XLOOKUP that is one formula: =XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),A2:A8). This guide shows that method step by step, explains when "next smaller" or "next larger" is what you really need, and gives a version for older Excel.

The sample data#

The examples use this list of laptop models and prices. It is not sorted, which is normal for real data:

AB
1ModelPrice
2A100450
3B200580
4C300720
5D400610
6E500899
7F600515
8G7001,050

The target, a budget of 670, is in E1. No price is exactly 670, so an exact lookup returns #N/A. The question is which model comes closest.

How to find the closest match with XLOOKUP and ABS#

The closest value is the one with the smallest difference from the target, whether it is above or below. In E2, type:

Excel formula
=XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),A2:A8)

The result is C300. Here is how it works:

  1. B2:B8-E1 subtracts 670 from every price: -220, -90, 50, -60, 229, -155, 380.
  2. ABS(...) turns each one into a positive gap: 220, 90, 50, 60, 229, 155, 380. ABS returns the absolute value, the number without its sign.
  3. MIN(...) finds the smallest gap: 50.
  4. XLOOKUP looks for 50 in the list of gaps and returns the model in the same position, C300 (720 is 50 above the budget).

This needs Excel 2021 or Microsoft 365, because XLOOKUP and formulas that work on a whole range at once (dynamic arrays) arrived there. To return the price instead of the model, change the last range to B2:B8. The XLOOKUP function guide covers each argument.

Closest vs next smaller vs next larger#

"Closest" can mean three different things, and the right formula depends on which one you need. XLOOKUP has a fifth argument, match_mode, for the other two:

You wantFormulaResult for 670
Nearest value either side=XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),A2:A8)C300 (720)
Next smaller or equal=XLOOKUP(E1,B2:B8,A2:A8,,-1)D400 (610)
Next larger or equal=XLOOKUP(E1,B2:B8,A2:A8,,1)C300 (720)

Notice that "next smaller" gives D400, which is 60 away, while the true closest is C300, 50 away. Use next smaller when the rule is "the highest value that doesn't go over", like tax bands or bonus tiers. Use next larger for "the smallest one that is big enough", like a box size or a shipping band. Both work on unsorted data. The guide to XLOOKUP approximate match has more tier examples.

How to find the closest match in older Excel with INDEX and MATCH#

In Excel 2019 and earlier there is no XLOOKUP, but INDEX and MATCH can do the same job. MATCH returns a position and INDEX returns the value at that position:

Excel formula
=INDEX(A2:A8,MATCH(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),0))

The result is again C300. The 0 tells MATCH to find the gap of 50 exactly. In older Excel, this is an array formula: press Ctrl+Shift+Enter on Windows, or Control+Shift+Return on a Mac, instead of Enter. Excel then shows curly brackets around the formula. If you press only Enter, you may get a wrong answer or #VALUE!. In Microsoft 365, plain Enter works.

If you have not combined these two functions before, read how INDEX MATCH works first, and see the MATCH function guide for the match types.

Next smaller or larger with MATCH on sorted data#

MATCH can also find the next smaller or next larger value without ABS, but only on sorted data. With match type 1, MATCH returns the position of the largest value that is less than or equal to the target. The list must be sorted from smallest to largest.

Sorted, the prices are 450, 515, 580, 610, 720, 899, 1,050. On that list:

Excel formula
=MATCH(670,B2:B8,1)

returns 4, the position of 610. Match type -1 finds the smallest value that is greater than or equal to the target, but it needs the list sorted from largest to smallest. If the data isn't sorted the right way, MATCH gives a wrong position without any warning, which is why the ABS method or XLOOKUP is safer. The article on the MATCH function explains all three match types.

What happens with ties, blanks and text#

The ABS method returns the first value in the list when two are equally close. With a target of 665, both 610 and 720 are 55 away. The formula returns C300, because C300 (720) comes before D400 (610) in the list. If you need a rule such as "prefer the cheaper one", sort the list by price first so the smaller value comes first.

A few other things to watch:

  • Blank cells count as 0, so a blank price can become the "closest" for a small target. Fill or remove blank rows.
  • Text in the number column makes the subtraction fail, and the formula returns #VALUE!. Check for numbers stored as text.
  • Closest text is a different problem. For partial text matches, such as a name that contains "Lap", use wildcards; see XLOOKUP wildcard matches.

Return more than one column or the gap itself#

Sometimes you want the gap as well as the item, for example to show how far over budget the closest model is. The gap is just the MIN part on its own:

Excel formula
=MIN(ABS(B2:B8-E1))

This returns 50. To see whether the closest price is above or below the target, subtract the target from the price XLOOKUP returns: =XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),B2:B8)-E1 gives 50, so it is 50 over. A negative result would mean under.

XLOOKUP can also return several columns at once. If column C held a screen size, =XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),A2:C8) would spill the model, price and screen size into three cells.

Practise it#

Try the exercise on this page: it finds the model closest to the budget with XLOOKUP and ABS. Then practise XLOOKUP match modes in a live spreadsheet, where you place values into tiers with next smaller and next larger matches and get instant feedback. For older files, the INDEX and MATCH lesson shows how to look up in any direction.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Which laptop model is priced closest to the budget in E1? Click E2 and use XLOOKUP with MIN and ABS on the prices in B2:B8, returning the model from A2:A8.

fx
ABCDEF
1
Model
Price
Budget
670
2
A100
450
Closest model
3
B200
580
4
C300
720
5
D400
610
6
E500
899
7
F600
515
8
G700
1050
9
10
11

Tip: ABS(B2:B8-E1) gives the gap for every price. Look up the smallest gap, MIN(...), in that same list of gaps, and return the model.

Practise this in a lesson

LessonXLOOKUP wildcards and match modesSearch partial names with XLOOKUP's wildcard mode, and place values into tiers with next-smaller and next-larger matches.LessonINDEX and MATCHCombine INDEX and MATCH to look up in any direction, including returning a column to the left of the one you search.Function guideXLOOKUPXLOOKUP explained with real examples: exact matches, looking left and custom not-found messages, plus a live exercise to try now.Function guideMATCHLearn how Excel's MATCH finds the position of a value, why the 0 matters, and how it powers INDEX/MATCH. Includes a live exercise.

Frequently asked questions

How do I find the nearest value in Excel?

+

Use =XLOOKUP(MIN(ABS(B2:B8-E1)),ABS(B2:B8-E1),B2:B8), where B2:B8 holds the values and E1 holds the target. It returns the value with the smallest difference from the target, above or below.

Does VLOOKUP find the closest match?

+

Not exactly. VLOOKUP with TRUE returns the largest value that is less than or equal to the target, on data sorted A to Z. That is the next smaller value, which is not always the closest.

How do I find the closest match without sorting?

+

Use the ABS method with XLOOKUP, or XLOOKUP with match_mode -1 or 1. Both work on unsorted data. MATCH and VLOOKUP approximate matches need sorted data.

What happens if two values are equally close?

+

The formula returns the first one it finds in the list. If you need the larger or smaller of the two, sort the list in that order first or add a rule to pick one.

Sources

  • XLOOKUP function - Microsoft Support
  • MATCH function - Microsoft Support
  • ABS function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The sample data
  2. How to find the closest match with XLOOKUP and ABS
  3. Closest vs next smaller vs next larger
  4. How to find the closest match in older Excel with INDEX and MATCH
  5. Next smaller or larger with MATCH on sorted data
  6. What happens with ties, blanks and text
  7. Return more than one column or the gap itself
  8. Practise it

Keep reading

Lookups· 6 min read

INDEX MATCH in Excel: The Beginner's Guide

INDEX MATCH is a lookup built from two functions. MATCH finds the position of a value in one column, and INDEX returns the item at that position from another column: =INDEX(A2:A9,MATCH(G2,B2:B9,0)). It can look left, it keeps working when columns are inserted, and it runs in every version of Excel.

Lookups· 7 min read

Find the Last Match in Excel With XLOOKUP

To find the last match, set XLOOKUP's sixth argument, search_mode, to -1 so it searches from the bottom up: =XLOOKUP(F2,A2:A8,C2:C8,"Not found",0,-1). It returns the value from the last row where column A equals F2, such as the most recent price in a list sorted oldest first. XLOOKUP needs Excel 2021 or Microsoft 365.

Lookups· 6 min read

The MATCH Function in Excel

MATCH finds a value in a row or column and returns its position, not the value itself. =MATCH("Marco",B2:B7,0) returns 4 if Marco is the 4th name in B2:B7. Always use 0 as the third argument for an exact match. MATCH is most useful inside INDEX, as =INDEX(A2:A7,MATCH(F2,B2:B7,0)), to look up in any direction.

More on lookups

  • How to Compare Two Lists in Excel
  • Find the First Non-Blank Cell in a Row or Column in Excel
  • How to Fix #N/A Errors in VLOOKUP and XLOOKUP
  • Fuzzy Match in Excel: Find Names That Nearly Match
  • HLOOKUP in Excel (and When to Use It)
  • INDEX Function in Excel: Return a Value by Position
All lookups articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free