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

Deriving High and Low Non-Zero Values

by Allen Wyatt
(last updated June 27, 2015)

4

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2332) 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: 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

Cut and Paste Formatting

What happens when you copy information from one document and paste it into another? It is possible for what you paste to look ...

Discover More

Viewing Your Custom Styles

If you develop a set of preferred styles, you may want to use those styles with a document you receive from someone else. ...

Discover More

Occurrences of a Text String within a Document

You may have a need to find out how many times a certain text string occurs within a document. You can find out manually ...

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

Combining Numbers and Text in a Cell

There are times when it can be beneficial to combine both numbers and text in the same cell. This can be easily done using a ...

Discover More

Returning the Smallest Non-Zero Value

In a series of values you may need to know the smallest value that isn't a zero. There is no built-in function to do this, ...

Discover More

Entering Formulas in Excel

The way you signify that you are entering a formula is to start a cell entry with an equal sign. Here is the reason why Excel ...

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}] 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 eight more than 2?

2015-06-30 11:33:21

Willy Vanhaelen

@Micky,

The MAX function works fine as long as there is at least one positive value in the range but if none of the values are positive it will return zero which is not the goal.


2015-06-29 11:42:29

Michael (Micky) Avidan

@Willy,
I'm more than happy to get feedbacks (and I'm not ashamed for, SOMETIMES, be proven being wrong).
However:
1) I do hope you'll check, again, your remark regarding my suggestion for using the MAX function.
2) As for the MIN suggestion - I used Allen's examples and didn't noticed they are all positive.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2015-06-28 12:37:22

Willy Vanhaelen

@Micky

The formulas you propose don't work if the range contains also negative numbers.

These ones do:
{=MIN(IF(C4:C8<>0,C4:C8))}
{=MAX(IF(C4:C8<>0,C4:C8))}


2015-06-27 05:44:52

Michael (Micky) Avidan

For the MIN I would suggest an Array formula, such as:
=MIN(IF(C4:C8>0,C4:C8))
For the MAX value, just use the simplest formula:
=MAX(C4:C8)
--------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


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.