Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Deriving High and Low Non-Zero Values

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.

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.

Related Tips:

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!

 

Comments for this tip:

Willy Vanhaelen    30 Jun 2015, 11:33
@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.
Michael (Micky) Avidan    29 Jun 2015, 11:42
@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
Willy Vanhaelen    28 Jun 2015, 12:37
@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))}
Michael (Micky) Avidan    27 Jun 2015, 05:44
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

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 4+5 (To prevent automated submissions and spam.)
 
          Commenting Terms
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2015 Sharon Parq Associates, Inc.