Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

 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.



Recommended Productivity Tools for Excel

Kutools for Excel Helps You Always Finish Work Ahead of Time, and Stand Out From Crowd

  • More than 300 powerful advanced features, designed for 1500 work scenarios, increasing productivity by 70%, give you more time to take care of family and enjoy life.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Brings Tabbed Browsing and Editing to Microsoft Office, Far More Powerful Than The Browser's Tabs

  • Office Tab is designed for Word, Excel, PowerPoint and Other Office Applications: 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!
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 · 22 days ago
    What if data is over column and not in a row?
  • To post as a guest, your comment is unpublished.
    Steve · 1 months 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.
    Aakash Naik · 9 months 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 · 1 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!