Conditional Formatting - Nearest to Zero

alexfooty

Board Regular
Joined
Dec 30, 2018
Messages
97
Office Version
  1. 2016
Platform
  1. Windows
In the cells below (AN25:BL25) I want to use conditional formatting to highlight the cell whose value is nearest to cell AM25 (Zero)

I have tried the formula =ABS(AN25-$AM$25)=MIN(ABS($AN$25:$BL$25-$AM$25)) which doesn't seem to work.

Also note that between each of the cells there are two hidden columns which do NOT contain any data or formulas.

Any help would be greatly appreciated.


Image 3.png
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Also note that between each of the cells there are two hidden columns which do NOT contain any data or formulas.
This is where the problem lies, an empty cell is equal to zero so is the closest to the criteria.

Trying to think of ways to make this work, will AM25 always be 0 or can it vary? Can any of the other cells be 0 as well?
 
Upvote 0
See if this does what you want.

20 08 31.xlsm
AMANAQATAWAZBCBFBIBL
250-2719-17-273-35-45-24-39
CF near value
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AN25:BL25Expression=ABS(AN25-$AM25)=AGGREGATE(15,6,ABS($AN25:$BL25)/($AN25:$BL25<>""),1)textNO
 
Upvote 0
Peter - works perfectly - thank you again for your help.

jasonb75 - thank you
 
Upvote 0
Peter - how would this formula change if I also wanted to highlight the number furthest from zero?
 
Upvote 0
Peter - works perfectly
Just checking - are you sure?
I just realised did not post the CF formula that I meant to.

Further to jasonb75's question about whether the AM value is always 0 or not.

If it is not always zero then my previous formula will not always work. Something like this instead

20 08 31.xlsm
AMANAQATAWAZBCBFBIBL
2511-2719-17-273-35-45-24-39
CF near value
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AN25:BL25Expression=ABS(AN25-$AM25)=AGGREGATE(15,6,ABS($AN25:$BL25-$AM25)/($AN25:$BL25<>""),1)textNO



If the AM value is always zero then you only need

20 08 31.xlsm
AMANAQATAWAZBCBFBIBL
250-2719-17-273-35-45-24-39
CF near value (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AN25:BL25Expression=ABS(AN25)=AGGREGATE(15,6,ABS($AN25:$BL25)/($AN25:$BL25<>""),1)textNO
 
Upvote 0
Peter - how would this formula change if I also wanted to highlight the number furthest from zero?
Furthest from zero or furthest from whatever is in column AM? Comes back to the same question about whether that value ever changes?
 
Upvote 0
AM25 is always zero. Your original formula worked fine. I changed the numbers in some of the cells and the correct cell was highlighted each time.
However, I've changed the formula to the 2nd one you posted, on the off chance that AM25 value may change in the future.
 
Upvote 0
I used your formula "=ABS(AN25-$AM25)=AGGREGATE(15,6,ABS($AN25:$BL25-$AM25)/($AN25:$BL25<>""),1)" to correctly highlight the cell value nearest to zero in cells AN25:BL25 using conditional formatting.
Is there a formula I can use in cells AN26:BL26 to rank these values so that the cell nearest to zero is ranked 1 and the cell furthest from zero is ranked 9?

Image 3.png
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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