Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Returning the Smallest Non-Zero Value.

Returning the Smallest Non-Zero Value

Written by Allen Wyatt (last updated July 17, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


1

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 (3260) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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

Making Banners in Word

Word can be used for printing a variety of document types. You may want to use the program to print a festive banner for ...

Discover More

Stopping Enter from being Pressed In a Form

If you create a form using Word, chances are good that you don't want a user to mess up the layout of the form by ...

Discover More

Viewing More than Two Places in a Worksheet

If your worksheet gets big enough, it is easy to spend a lot of time navigating back and forth between different areas. ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Character Replacement in Simple Formulas

Do you see some small rectangular boxes appearing in your formula results? It could be because Excel is substituting that ...

Discover More

Filling References to Another Workbook

When you create references to cells in other workbooks, Excel, by default, makes the references absolute. This makes it ...

Discover More

Summing Digits in a Value

Want to add up all the digits in a given value? It's a bit trickier than it may at first seem.

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}] (all 7 characters, in the sequence shown) 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 6 - 0?

2022-05-02 17:42:58

Greg Miller

Allen,

Thank you for this helpful tip. I came across while search for solutions to finding the three smallest non-zero values.

Since both SMALL and MIN ignore logical values, the solution works well. For example,
when A1:A5 is { 2; 0; 1; 14; 9 }
then A1:A5<>0
returns { 2; FALSE; 1; 14; 9 }
Since SMALL will ignore the logical value, SMALL(A1:A5<>0,{1;2;3}) will return 1; 2; 9. Since I am using EXCEL 365, I used SEQUENCE(3) instead of the hard-coded array.


I have commonly used the "double unary" of two negatives to coax numerical values out of logical values, but it was a pleasant discovery to realize that the trait of many EXCEL functions to ignore text, empty cells, and logical values can be put to good use.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.