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

# Deriving High and Low Non-Zero Values

by Allen Wyatt
(last updated February 17, 2020)

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

Fixing Odd Sorting Behavior

When you sort data that contains both numbers and text, you may not get exactly the result that you expected. To know ...

Discover More

Viewing Same Cells on Different Worksheets

When switching from one worksheet to another, you might want to view the same portion of the new worksheet that you were ...

Discover More

Differing Column Widths when Pasting

When you move information from one table to another, you may be faced with the problem of making that information fit ...

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)

Locating a Single-Occurrence Value in a Column

Given a range of cells containing values, you may have a need to find the first value in the range that is unique. This ...

Discover More

Searching for a Value Using a Function

Searching for a value using Excel's Find tool is easy; searching for that same value using a formula or a macro is more ...

Discover More

Limiting a Calculated Value to a Range

If you want to limit what is returned by a formula to something between lower and upper boundaries, the solution is to ...

Discover More
##### Subscribe

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

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 9 + 6?

2019-11-07 18:24:09

Peter Atherton

To All
Looking up MINIFS function confirms that you need Excel 2019 or 365 for this function. The page is
https://support.office.com/en-gb/article/minifs-function-6ca1ddaa-079b-4e74-80cc-72eef32e6599
The page has three examples and for those without the latest version, possible array formulas are;

ex1. {=MIN(IF(B2:B7=1,A2:A7))}
ex2. {=MIN(IF(B3:B6="a",A2:A5))}
ex3 {=MIN(IF((B2:B7="b")*(D2:D7>100),A2:A7))}

Does anyone have other solutions, or a vb function for this?

2019-11-07 13:31:23

Thomas Papavasileiou

Correction for the second formula
Another easy to use array formulas are:

=MIN(IF(ref<>0,ref)) for minimum
=MAX(IF(ref<>0,ref)) for maximum

"ref" stands for an area i.e. b2:k2
The formulas ignore any blank cells in "ref"

Do not forget that these are array formulas. Use ctrl + shift + enter. The formula will show as {=MIN(IF(ref<>0,ref))}

2019-11-07 13:29:45

Thomas Papavasileiou

Another easy to use array formulas are:

=MIN(IF(ref<>0,ref)) for minimum
=MIN(IF(ref<>0,ref)) for maximum

"ref" stands for an area i.e. b2:k2
The formulas ignore any blank cells in "ref"

Do not forget that these are array formulas. Use ctrl + shift + enter. The formula will show as {=MIN(IF(ref<>0,ref))}

2019-11-06 18:09:47

Robert H. Gascon

For highest, AGGREGATE can return the desired result, like this: =AGGREGATE(14,6,C4:C8/(C4:C8<>0),1)For lowest, change 14 to 15.

2019-11-05 06:13:20

Steve Jez

This post needs an edit to bring it up to date with the MINIFS function eg.

=MINIFS(C6:C14,C6:C14,"<>"&0)
Syntax - Range to obtain minimum from, Range for criteria, Criteria
In this example the criteria range is the same as the range to find the min of.

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

The following assumes the search list contains no negative values.
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

I think you can use the 2nd argument part of the formula without the IF statement and use only 2 functions.
=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

Here is another non-array formula that will work and is a little shorter and less complex using 3 functions instead of 5 and 3 range references instead of 4:

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

##### 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.