Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Returning the Smallest Non-Zero Value.

Returning the Smallest Non-Zero Value

by Allen Wyatt
(last updated May 22, 2018)

13

Mark is hoping to find the smallest non-zero value in a set of values. For example, if he has the values 0,0,3,0,6,8, he would want the value 3 (the smallest non-zero value) returned by a formula. Mark knows he can use the SMALL function with the second argument calculated by using a COUNTIF to count the number of zeroes in the range. However, he wants to use this inside of an array formula, and Excel can't handle COUNTIFs inside of array formulas.

Since Mark is only interested in array formulas (entered by pressing Ctrl+Shift+Enter), then there are a couple that could be used. The following array formula is worth looking at first:

=MIN(IF(A1:A5=0,MAX(A1:A5),A1:A5))

Assuming the values to be examined are in A1:A5, this formula puts together an array of non-zero values from that range. If the value in one of the cells is 0, then the MAX function kicks in, returning the largest value from the range. (This essentially kicks the value at that cell—originally 0—out of consideration as the smallest value.) If the value in one of the cells is not 0, then the actual value is returned. The MIN function then returns the lowest value from the array.

You can make the formula even shorter by turning it around in this manner:

=MIN(IF(A1:A5<>0,A1:A5))

Note that in this version, the value in each cell of the range is checked to see if it isn't 0. If it isn't, then the value is returned. If it is 0, then nothing is returned. Again, the MIN function is used to return the lowest value from the array.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9330) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Returning the Smallest Non-Zero Value.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Weekdays in a Month

Want to find out how many of a particular weekday occur within a given month? Here's how you can find the desired ...

Discover More

Enhancing Word Documents with Dynamic Fields (Special Offer)

Enhancing Word Documents with Dynamic Fields can help make document creation easier. Another way you can increase ...

Discover More

Selecting a Column or Row in a Table

Selecting rows and columns in tables is a common task. Because of this, Word provides a couple of ways you can accomplish ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Ignoring N/A Values in a Sum

You can use some of Excel's worksheet functions across a range or worksheets, but not all of them. One that has problems ...

Discover More

Calculating the Distance between Points

Want to figure out how far it is between two points on the globe? If you know the points by latitude and longitude, you ...

Discover More

Calculating an Expanding Square

When doing a systematic search for rescue purposes, it isn't unusual to implement what is termed an "expanding square." ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 1?

2020-06-10 11:52:48

J. Woolley

See my MINIF (and MAXIF) function at https://sites.google.com/view/MyExcelToolbox/
The syntax is similar to COUNTIF and SUMIF. For the example in the Tip, use
=MINIF(A1:A5,"<>0")
Do NOT enter as an array formula.


2020-06-09 16:40:57

Lisa Snyder

I have Excel 2016 and the formula =MIN(IF(A1:A5<>0,A1:A5)) gives me an answer of '#VALUE!.' If I press f9 in the cell, it gives me the correct answer and then deletes the formula. I sometimes have negative numbers and I need to be able to find those. If I look at the function arguments, it gives me the correct answer also. I'm going to try to attach a screen print of my issue. Thanks!

[{fig}}


2020-02-04 16:55:30

Adam

I found another way to do this. It's a bit of a thinker but once you understand it, it's pretty simple. It works if you have all positive OR all negative values. (I will write this for all positive, just invert for all negative.)

Start by subtracting a very small amount from all the numbers, then invert them all. All the zero's will be highly negative values, and the minimum above zero will now be the maximum. Reverse these steps after taking the maximum to reproduce the minimum non-zero value. NOTE: This works great with array formulas (i.e. Ctrl+Shift+Enter).


2018-05-22 12:56:15

Allan

Why not just sort from largest to smallest and delete the zeros.


2018-05-22 03:30:20

gerdami

Microsoft has introduced MINIFS() - which would do the job - in Excel 2016 but only in the 365 version :-(
https://support.office.com/en-us/article/minifs-function-6ca1ddaa-079b-4e74-80cc-72eef32e6599


2016-11-30 15:04:36

TerryG

Awesome, thank you so much!!

Ditto on the Ctrl+Shift+Enter AFTER entering the formula, or it won't work!!


2016-08-25 00:19:05

Ayush

Thanks a lot ! Just remember to press ctrl+shift+enter after entering the formula. Otherwise it wont work.


2016-05-20 06:17:43

Michael (Micky) Avidan

@Rod,
The following example is more appropriate.
(see Figure 1 below)


Figure 1. 




2016-05-20 06:15:13

Michael (Micky) Avidan

@Rod,
Both work EXACTLY(!) as expected.
(see Figure 1 below)


Figure 1. 




2016-05-19 06:50:45

Rod bennett

These did not work for me. I had to use the small function. I am using Excel 2013;

=MIN(IF(A1:A5=0,MAX(A1:A5),A1:A5)) returns the maximum value

=MIN(IF(A1:A5<>0,A1:A5)) returns zero


2016-02-14 05:24:01

Mags

Thanks Willy, entering the formula with Ctrl+Shift+Enter got it right.


2015-11-26 12:09:31

Willy Vanhaelen

Did you enter the formula with Ctrl+Shift+Enter?


2015-11-25 19:38:31

tiki

None of the above worked.
I have four vendor columns some with prices some with $00.00, but none of the the formulas that I have tracked down can go to the next low number if it has a $00.00 value in the cell. I have tried about twenty or so combinations.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.