How to highlight the closest value in a list to a given number in Excel?

Supposing, you have a list of numbers, now, you may want to highlight the closest or several closest values based on a given number as following screenshot shown. Here, this article may help you to solve this task with ease.

doc highlight closest value 1
doc highlight closest value 2

Highlight the closest or closest n values to a given number with Conditional Formatting


arrow blue right bubble Highlight the closest or closest n values to a given number with Conditional Formatting

To highlight the closest value based on the given number, please do as follows:

1. Select the number list that you want to highlight, and then click Home > Conditional Formatting > New Rule, see screenshot:

doc highlight closest value 3

2. In the New Formatting Rule dialog box, do the following operations:

(1.) Click Use a formula to determine which cells to format under the Select a Rule Type list box;

(2.) In the Format values where this formula is true text box, please enter this formula: =ABS(A2-$D$2)=MIN(ABS($A$2:$A$15-$D$2)) (A2 is the first cell in your data list, D2 is the given number you will compare, A2:A15 is the number list you want to highlight the closest value from.)

doc highlight closest value 4

3. Then click Format button to go the Format Cells dialog box, under the Fill tab, choose one color you like, see screenshot:

doc highlight closest value 5

4. And then click OK > OK to close the dialogs, the closest value to the specific number has been highlighted at once, see screenshot:

doc highlight closest value 6

Tips: If you want to highlight the closest 3 values to the given values, you can apply this formula in the Conditional Formatting, =ISNUMBER(MATCH(ABS($D$2-A2),SMALL(ABS($D$2-$A$2:$A$15),ROW($1:$3)),0)), see screenshot:

doc highlight closest value 7

Note: In the above formula: A2 is the first cell in your data list, D2 is the given number you will compare, A2:A15 is the number list you want to highlight the closest value from, $1:$3 indicates that the closest three values will be highlighted. You can change them to your need.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Phil · 1 years ago
    What if data is over column and not in a row?
  • To post as a guest, your comment is unpublished.
    Steve · 1 years ago
    This is useful, but how would I do the following please. Text is in Col A, the number range is in Col B: when the average has been found using the above method and is thus highlighted, I need the corresponding cell in Col A to also highlight.

    Thank you
  • To post as a guest, your comment is unpublished.
    aak.293n@gmail.com · 2 years ago
    Hi! I am very thankfull to u for this as this solved my problem for a presentation to a client. However I am looking for something more for my future presentations. like when u say highlight 3 closest(n) values i want to highlight them as: 1) the most closest with Green. 2) the least closest in red and the 3) value which is between most and least closest in yellow. Can u please help me to achieve this. As per the example my d2 value is live updating every minute so i want to know where exactly my d2 value lies on scale of a range(eg. Number list). This will add a brand finish to my presentations. Point to note i am using excel 2007 as many of my clients are still using the same. Just to avoid any compatibility issues i avoid latest versions. Thanks in advance and many regards. :)
  • To post as a guest, your comment is unpublished.
    Sebastine · 2 years ago
    An excellent resource for highlighting the closest value. Since the logic is same , won't it work in Google Sheets? Anyway it is not working in Google Sheets. Would be obliged if you could please clarify!