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: Deriving High and Low Non-Zero Values.

Deriving High and Low Non-Zero Values

Written by Allen Wyatt (last updated July 31, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

There may be times when you need to derive the smallest (or largest) value from a range, unless the smallest (or largest) value is zero. For instance, you might have a range of values such as {0, 3, 1, 4, 2}. In this case, the lowest value is zero, but the value you really want returned is 1.

There is no intrinsic function within Excel to return a value as stipulated here. However, you can create a formula that will do the trick. Assuming that the range of values you want to analyze are in C4:C8, the following formula will return the lowest non-zero value:

=IF(MIN(C4:C8)=0,SMALL(C4:C8,COUNTIF(C4:C8,"=0")+1),MIN(C4:C8))

This formula uses the MIN function to determine if the lowest value in the range is zero. If it is, then the SMALL function is used to derive the lowest value, excluding the zeros. (The COUNTIF function returns the number of zeros in the range, and therefore tells SMALL which item from the range to pick.)

A small change to the formula allows it to be used to return the largest non-zero number in a range:

=IF(MAX(C4:C8)=0,LARGE(C4:C8,COUNTIF(C4:C8,"=0")+1),MAX(C4:C8))

These formulas will work for any range, unless the range is made up entirely of zeros. In that instance, a #NUM! error is returned.

If you are using Excel 2019 or Excel in Office 365, you can use the new MINIFS function. It would be used in this manner for this example:

=MINIFS(C4:C8,C4:C8,"<>"&0)

More information on the MINIFS function can be found on this Microsoft Office support page:

https://support.office.com/en-gb/article/minifs-function-6ca1ddaa-079b-4e74-80cc-72eef32e6599

If you prefer to use array formulas, then you can make the formula much shorter. This version returns the lowest non-zero value:

=MIN(IF(C4:C8=0,9^9,C4:C8))

Remember to enter it using Ctrl+Shift+Enter. It also suffers from a problem if all the values in the range are 0; in that case it returns 387420489, which is 9^9. (It would also return that value if all the values in the range were greater than 387420489.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9750) 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: Deriving High and Low Non-Zero Values.

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

Scanning and Fixing System Files

Is your system running a bit flakey at times? If you think the culprit might be a problem with some of your system files, ...

Discover More

Data Source File in Word 2003

The security features introduced in Word 2003 resulted in a change in the dialog boxes you see when opening mail-merge ...

Discover More

Replacing Some Smart Quotes

Smart quotes look great in a document, but may not be right for all instances of quote marks or apostrophes. If you need ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Counting String Occurrences in Odd Rows

Counting the number of times text occurs within a range of cells can be relatively easy. If you need to only count ...

Discover More

Calculating an Average within a Date Range

Need to find an average of the values that fall within a date range? Excel provides a number of ways you can do this, ...

Discover More

Saving Common Formulas

Got some formulas you slaved over and want to use in lots of workbooks? This tip presents some helpful ideas on how you ...

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 5 + 3?

2021-08-04 09:09:07

Mark Winfield

Hi Allen,

Thanks for your many useful tips - I've followed your site for years and always enjoy reading the tips you write.

A question on this current tip 'Deriving High and Low Non-Zero Values'; I follow the logic of your first formula in the tip but wonder whether you could halve its length by getting rid of the 'IF' and the two 'MIN' functions, and just use:

=SMALL(C4:C8,COUNTIF(C4:C8,"=0")+1)

Have I missed something? Kind regards, Mark


2021-07-31 10:23:39

J. Woolley

You can also use the MINIF and MAXIF functions in My Excel Toolbox:
=MINIF(C4:C8,"<>0")
=MAXIF(C4:C8,"<>0")
MINIF and MAXIF (which are not built-in Excel functions) are designed analogous to SUMIF (which is built-in).
See https://sites.google.com/view/MyExcelToolbox/


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.