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: Finding the Lowest Numbers.

Finding the Lowest Numbers

by Allen Wyatt
(last updated December 13, 2014)

12

You may have a need at some point to find the lowest numbers in a list of values. This is relatively easy to do if you use the SMALL worksheet function. The function takes two parameters: the range of the values to be evaluated and an indicator of which smallest number you want. For instance, the following will return the second lowest number in the range of A1:A100:

=SMALL(A1:A100,2)

If you wanted to know the two lowest numbers in the range, then use two formulas containing the SMALL function—one with 1 as the second parameter (for the lowest number) and one with 2 as the second parameter (for the second lowest number).

There are situations, of course, where the two smallest numbers in the range could actually be the same number. For instance, if the lowest number is 3 and there is a second 3 in the list, then both the lowest numbers will be the same. If you want the two lowest unique numbers then you will need to use a macro to determine them.

Function SMALLn(rng As Range, n)
    Application.Volatile
    SMALLn = False
    If n < 1 Then Exit Function
    Dim i As Long, j As Long, k As Long, min, arr, arr2
    arr = Application.Transpose(rng)
    ReDim arr2(n - 1)
    min = Application.WorksheetFunction.Min(arr)
    j = UBound(arr)
    k = 0
    arr2(k) = min
    For i = 1 To j
        If Application.Small(arr, i) <> arr2(k) Then
            k = k + 1
            arr2(k) = Application.Small(arr, i)
            If k = n - 1 Then
                SMALLn = arr2(k)
                Exit For
            End If
        End If
    Next i
End Function

This user-defined function is used in the following manner:

=SMALLn(A1:A100,2)

When called like this, the function returns the second lowest unique value in the specified range.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10944) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Finding the Lowest Numbers.

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

Limiting Entries to Numeric Values

When creating a worksheet, you may need to limit what can be entered into a particular cell. Using data validation you can ...

Discover More

Sorting for a Walking Tour

Want to sort addresses by even and odd numbers? By using a formula and doing a little sorting, Excel can return the addresses ...

Discover More

Create a Template that Stops Styles from Being Added to a Document

Limiting which styles a user can use or add to a document can be a tricky task. Fortunately Word has advanced to the point ...

Discover More

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!

More ExcelTips (ribbon)

Returning Item Codes Instead of Item Names

The data validation capabilities of Excel are really handy when you want to limit what is put into a cell. However, you can't ...

Discover More

Phantom Counts

Two common worksheet functions used to count things are COUNT and COUNTA. Not understanding how these functions treat cell ...

Discover More

Using the ABS Function

Need to find the absolute value of a number? That's where the ABS function comes into play.

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 8 - 2?

2016-09-07 08:48:51

Ron Owens

I need a formula to select the low four numbers from a column and then add those four numbers.

These are golf match scores. I need to select the low four for a team then add those four scores for a team total.


2014-12-14 15:38:24

Michael (Micky) Avidan

@Locke,
1) No problem (as for your addition to my formula).
2) in the UDF - you may omit the: nn = Rng.Count
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-12-14 14:12:39

Lock Garmin

@Micky

No problem. In the cases where you can make the assumption that your range is all numbers (which would be most cases) I would use your solution in a heart beat. I just wanted to add to your solution so that it behaved a little more like the SMALL/LARGE functions. You're formula solution is perfectly valid. :)

Nice UDF!


2014-12-14 06:59:04

Michael (Micky) Avidan

@Locke,
My suggested formula was written as per the above tip - therefor I didn't considered textual values within the range.
Here is my suggestion for a "sufisticated" UDF.
a) Rng is for the Range of cells.
b) The second argument is the position k.
c) The last argument should be "S" for Small or "L" for Large.
----------------------------------------------
Function Large_SmallUnique(Rng As Range, k, LS)
Dim NewList As New Collection
nn = Rng.Count
On Error Resume Next
For Each CL In Rng
NewList.Add CL, CStr(CL)
Next
ReDim arr(NewList.Count)
For P = 1 To NewList.Count
arr(P) = NewList(P)
Next
If UCase(LS) = "L" Then
Large_SmallUnique = Application.Large(arr, k)
Else
Large_SmallUnique = Application.Small(arr, k)
End If
End Function
-------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-12-13 19:18:03

Michael (Micky) Avidan

@Roy,
Allens coding is a USER DEFINED FUNCTION - and as such it MUST be typed into a Module and not in both places you have mentioned.
My previous disclosure remains the same.
Try to study the following link:
http://dmcritchie.mvps.org/excel/getstarted.htm
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-12-13 15:46:46

Locke Garmin

@Roy

You'll need to create a module. UDFs don't work in Sheet or Workbook objects.


2014-12-13 15:41:58

Locke Garmin

@Micky

In playing with your formula I discovered for the first time that SMALL/LARGE ignore TRUE/FALSE values. Always a new discovery! Not sure how I never realized it before.

I noticed that the formula breaks if your range contains text or boolean values. This can be overcome with the following modification:

=SMALL(IF(FREQUENCY(MATCH($A$1:$A$10,$A$1:$A$10,0),MATCH($A$1:$A$10,$A$1:$A$10,0)),A$1:A$11),ROW(A1))


2014-12-13 10:00:54

Ralph Shumaker

In a large worksheet, I decide to find the smallest number, so I entered =, then END, then Home. to find all active cells. I then edited the formula to =small(A1:K7580) and received an error. then I added ,2) to the formula and got a 0. So I increased the decimals and still received a zero. So I thought the lowest number must be zero or the formula will not work if some cells contain text, so I edited the formula to =large(A1:a100,1) and received a large number. I then edited my small formula and received a -121 and the other formulas re-computed. Now I'm wondering why my initial entry did not work.


2014-12-13 06:52:59

Roy

@Micky

My ignorance is showing, I copied Allens coding into both sheet1 and thisworkbook but the function was not available. What did I do wrong?

Roy


2014-12-13 06:13:48

Michael (Micky) Avidan

@Roy,
Correct assumption, especially as far as my formula is concerned.
***Disclosure:
I didn't examine the proposed UDF.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-12-13 06:07:52

Michael (Micky) Avidan

No need for a UDF.
Assume the range of numbers are in A1:A10:
3
-3
6
7
-2
8
5
5
-2
-3
Now, type the following formula into cell D1 and copy down as far as needed.
=SMALL(IF(FREQUENCY(A$1:A$10,A$1:A$10),A$1:A$11),ROW(A1))
Double click to see a pictured demonstration:
http://postimg.org/image/phqgmhff3/
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL



2014-12-13 06:00:51

Roy

One assumes you could also use the principle for obtaining the LARGEst unique numbers.


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.