Skip to main content

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.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


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!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
=ABS(A2-$D$2)=MIN(ABS($A$2:$A$15-$D$2)) данная формула не работает. Пробовал exel 2010 и 2013. Если использовать вторую формулу, ругается на ошибку.
This comment was minimized by the moderator on the site
Hello friend,

Sorry to hear that. But I did try the two formulas and they both work perfectly. Please see the screenshots.
Here is the tip. Please make sure you choose the right range, in my case here, it is A2:A15. Then click Home > Conditional Formatting to set up the rules. Please have a try. If the problem still remains, please provide me with more details so I can help you. Have a nice day.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
Hi, das hilft mir bereits sehr weiter, danke!Gibt es aber auch eine Möglichkeit, die Formel aus Schritt 2 ohne "$"-Zeichen zu verwenden? Das würde das Kopieren der bedingten Formatierung erleichtern...
This comment was minimized by the moderator on the site
What if data is over column and not in a row?
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Were you able to figure this out? I would also like to know about expanding the format to the remaining row.
This comment was minimized by the moderator on the site
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. :)
This comment was minimized by the moderator on the site
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!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations