Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 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

Written by Allen Wyatt (last updated October 17, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

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))

Don't forget, again, that this is an array formula requiring the use of Ctrl+Shift+Enter to enter the formula. 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.

Just a quick note regarding using these as array formulas: Microsoft changed the way that Excel works, internally, in late 2019/early 2020. This did away with the need to enter array formulas using Ctrl+Shift+Enter. Thus, if you are using the version of Excel provided with Office 365, you can get by with using these formulas without Ctrl+Shift+Enter.

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 Microsoft 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

Setting Subscript Depth in the Equation Editor

You can specify exactly where subscripts appear in your equations.

Discover More

Displaying the Print Dialog Box in a Macro

Want to print a document by using a macro? One way is to display the Print dialog box and allow the user to interact with ...

Discover More

Moving Items On a Menu

Want your copy of Excel to reflect the way you want to work with the interface? Fortunately, you can modify where various ...

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 (ribbon)

Totaling Across Worksheets

Want to sum the values in the same cell on a range of worksheets? It's not as easy as summing a range on the same ...

Discover More

Counting Alphabetic Characters in a String

Need to find out how many times a certain letter appears in a text string? It's easy to do if you rely on the SUBSTITUTE ...

Discover More

Identifying Values that Don't Follow a Specific Pattern

When you store textual information in a worksheet, it can be helpful to figure out if that information follows a pattern ...

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 2 + 2?

2022-06-11 15:00:04

Steve

Thank you for actually VERIFYING that the solution works; I've seen so many people on StackExchange post 'solutions' that they didn't even try, that don't work, wasting everyone's time.


2020-10-19 07:32:12

Alex Blakenburg

If you have office 365, you could use
=MIN(FILTER(A1:A5,(A1:A5)>0)) - if you only want the lowest non-zero positive
=MIN(FILTER(A1:A5,(A1:A5)<>0)) - if you do not want to exclude negatives (and want the true non-zero minimum), of course will give the same result as the above if there are no negatives.


2020-10-17 11:41:49

J. Woolley

You might be interested in the MINIF and MAXIF functions in My Excel Toolbox: https://sites.google.com/view/MyExcelToolbox/
You might also consider the MINIFS and MAXIFS functions in Excel 365/2019.


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.