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

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 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, and 2013. You can find a version of this tip for the older menu interface of Excel here: **Deriving High and Low Non-Zero Values**.

**Save Time and Supercharge Excel!** Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out *Excel 2010 VBA and Macros* today!

If you keep phone numbers in an Excel worksheet, you may need a way to add an area code to the beginning of all of the ...

Discover MoreUsing Excel to maintain lists of information is not unusual. When working with the list you may need to determine how ...

Discover MoreWhen compiling statistics on a collection of data points, you may want to know whether a particular value is the "highest ...

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

2016-04-21 09:02:54

Vaibhav

Simplest formula according to me would be:

=SMALL($C$4:$C$8,COUNTIF($C$4:$C$8,0)+1)

Cheers!!

2015-08-19 11:12:09

Steven M

Why does the formula for finding the Largest non-zero need the COUNTIF? Doesn't that lead to an incorrect answer?

Simply using the MAX function works for all cases where there is at least one value greater than zero. One could add an IF statement to return an error message for the case of all zero values.

2015-08-15 20:03:44

S adams

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

You can also wrap the formula in a IFERROR function to return text such as "All Zeros" if desired.

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

2015-08-15 14:34:28

Locke Garmin

=SMALL(C4:C8,SUMPRODUCT((C4:C8=0)*(MIN(C4:C8)=0))+1)

Plus finding the largest non-zero number only requires changing 2 of the formulas instead of 3:

=LARGE(C4:C8,SUMPRODUCT((C4:C8=0)*(MAX(C4:C8)=0))+1)

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.

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

Copyright © 2019 Sharon Parq Associates, Inc.

## Comments