Excel – Find closest value to 0 in range of values in Excel (with non-numeric fields)

absolute-valueexcelmin

I have a range of cells in Excel with various positive and negative numbers. The value of the cell is determined by an IF formula, and some of the cells in the range have no value ("").

I need to find the absolute value of the nearest cell to 0. So if I had a list of -10,-5,-1, 3, 6, and "": I need to get a result of 1.

I've tried multiple approaches but the fact that I have non-numeric cells seems to be an issue which is causing errors.

What I've tried:

{=Min(ABS(A1:D10))}, where I press Ctrl-Shift-Enter (returns an error because of non-numerics)

{=IF(MAX(D3:D22)<=0,-1,IF(MIN(ABS(D3:D22))=MIN(ABS(IF(D3:D22>0,D3:D22,MAX(D3:D22)))),1,-1))*MIN(ABS(D3:D22))}, where I press Ctrl-Shift-Enter (returns an error because of non-numerics)

{=IF(OR((D3:D22)>0),MIN(ABS(D3:D22)),-MIN(ABS(D3:D22)))}, where I press Ctrl-Shift-Enter (returns an error because of non-numerics)

Best Answer

=MIN(ABS(IF(ISNUMBER(D3:D22),D3:D22,9999)))

This is an array formula and must be confirmed with Ctrl+Shift+Enter

should do the trick

or better use:

=INDEX(D3:D22,MATCH(MIN(IF(ISNUMBER(D3:D22),ABS(D3:D22))),ABS(D3:D22),0))

This is an array formula and must be confirmed with Ctrl+Shift+Enter

doesn't care about text or empty cells but having 0 as number will count... also negative numbers will be negative (if you allways want positive you need to ABS the whole formula...

Related Topic