Conditional Format single cell in range that's closest to s specific value in another cell

Robert_G

New Member
Joined
Jul 13, 2018
Messages
48
I have descending numbers from A1-A21

I have a value in D5

I would like to conditional format column A to highlight red the value that's closest to D5 by a matter of rounding down.







9
307wx2t.png


9
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
One way wound be to enlist the use of a helper column.
I am not sure which value you want to round down, but you could write a formula that takes absolute value (ABS function) of the difference between the value in column D5 with each value in column A.
Then, you could take the MIN value in the calculated column and use that to format the appropriate value in column A.
 
Upvote 0
The value I would want to round down would be in D5 compared to the constants in column A.


The value I picked for this demo (D5) is exactly in the middle of A4 & A5. I could have round up and chose A4 but for my purposes, the value I would rather have is more a conservative approach which would make me want to round down & have A5 highlighted.
 
Upvote 0
The value I would want to round down would be in D5 compared to the constants in column A.


The value I picked for this demo (D5) is exactly in the middle of A4 & A5. I could have round up and chose A4 but for my purposes, the value I would rather have is more a conservative approach which would make me want to round down & have A5 highlighted.
OK, did you try what I suggested?
Is making use of a Helper column acceptable?
 
Upvote 0
Yes I got it to work. Took some doing but I was able to set the MIN value you suggested and then an IF statement to match with the original column & a conditional format to highlight when they equaled each other, (if I just wrote that correctly) but it works.

Thanks-
 
Last edited:
Upvote 0
Not quite. I think the way I was thinking is a little less steps that what you ended up doing.

So, in column B, I entered a formula that takes the difference between the values in column A and cell D5, and takes the Absolute Value of the difference.
So, the formula for B1 would look something like this:
Code:
=ABS(ROUNDDOWN(A1,0)-$D$5)
and then copy that formula down to B21 (I am still a little unclear of where exactly you want to to apply the ROUNDDOWN, so adjust as necessary).

Then, apply the Conditional Formatting by selecting cells A1:A21, and then enter in this Conditional Formatting formula:
Code:
=B1=MIN(B$1:B$21)
and apply the formatting option you desire (red highlight).
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top