Consulting

Results 1 to 5 of 5

Thread: Solved: Smallest 3 numbers in range

  1. #1

    Solved: Smallest 3 numbers in range

    Hi,

    I have a range of numbers and would like to have a formula that gives me back number if it is one of 3 smallest or else gives me zero.

    Numbers are in range A1:A10 and formula will be in range B1:B10.

    I have done the following formula:

    =IF(OR(A1=SMALL($A$1:$A$10,1),A1=SMALL($A$1:$A$10,2),A1=SMALL($A$1:$A$10,3) ),A1,"")

    This formula works but it is very long and if I wanted for example 6 smallest numbers the formula would double in size.

    I would like to know if there is a way to make this formula shorter!

    Thanks,
    Nix


  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    I am utterly unsure about this, but this seems to work:

    =SMALL(A1:A10,TRANSPOSE({1,2,3,4,5,6}))

    ...entered as an array formula.

  3. #3
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    Hi Nicolaf,

    An easy way is to use a helper column (say range c1:C6), which you can hide, to identify the SMALL numbers with formula
    =SMALL(A$1:A$15,ROW())
    then use the following formula in B1 (and copy down)
    =IF(ISERROR(MATCH(A1,$C$1:$C$6,0)),0,A1). Adjust the $C$1:$C$6 range for the number of items you want to test for.

    You can also use the IFERROR function if you have excel 2007 or later (but I've only got excel 2003 at home to give a tested formula).
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Try =IF(A1<=SMALL($A$1:$A$10,3), A1, "")
    Last edited by mikerickson; 03-05-2013 at 08:00 AM.

  5. #5
    It works great thanks!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •