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

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.

*Note:*

If you would like to know how to use the macros described on this page (or on any other page on the *ExcelTips* sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (10944) 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: **Finding the Lowest Numbers**.

**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!

When performing a statistical analysis on a large dataset, you may want to use GEOMEAN to figure out the geometric mean ...

Discover MoreFinding a square root is easy because Excel provides a worksheet function for that purpose. Finding a different root may ...

Discover MoreWhen working with text in a formula, you may need to extract the left-most characters from a string of text or from a ...

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

2016-09-07 08:48:51

Ron Owens

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

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

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

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

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

@Roy

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

2014-12-13 15:41:58

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

2014-12-13 06:52:59

Roy

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

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

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.

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 © 2020 Sharon Parq Associates, Inc.

## Comments