+ Reply to Thread
Results 1 to 9 of 9

Nearest one or two or three numbers in a row of data

  1. #1
    Registered User
    Join Date
    06-16-2012
    Location
    london, england
    MS-Off Ver
    Excel 20101
    Posts
    11

    Nearest one or two or three numbers in a row of data

    Hi Everyone,

    I have a problem tody. I tried in different ways but could not solve it.

    Lest's say I have the following row of Data:

    61 49 55 45 48 69 79 51

    I need a code (Excel formula) that find the closest two or three numbers to 50 but lower than 50 (which in this case are 49 48 and 45)

    I will then add them to each other and put the result in a single cell

    Notes : the data must be in Row. Mine is Excel 2010.

    Thanks in Advance for your help

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Nearest one or two or three numbers in a row of data

    =SUM(LARGE(A1:H1,COUNTIF(A1:H1,">=50")+1),LARGE(A1:H1,COUNTIF(A1:H1,">=50")+2),LARGE(A1:H1,COUNTIF(A1:H1,">=50")+3)) maybe
    or even
    =SUM(LARGE(A1:H1,{1,2,3}+COUNTIF(A1:H1,">=50")))
    Last edited by martindwilson; 06-16-2012 at 08:11 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Nearest one or two or three numbers in a row of data

    cross posted at mrexcel
    http://www.mrexcel.com/forum/showthr...-a-row-of-data

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Nearest one or two or three numbers in a row of data

    With several helpcolumn I come to this solution.

    See the golden cells.
    Attached Files Attached Files

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Nearest one or two or three numbers in a row of data

    How about an amendment to Martin's formula:

    =SUM(LARGE(A1:H1,COUNTIF(A1:H1,">=50")+{1,2,3}))

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Nearest one or two or three numbers in a row of data

    @cutter been there done that lol

  7. #7
    Registered User
    Join Date
    06-16-2012
    Location
    london, england
    MS-Off Ver
    Excel 20101
    Posts
    11

    Re: Nearest one or two or three numbers in a row of data

    Quote Originally Posted by oeldere View Post
    With several helpcolumn I come to this solution.

    See the golden cells.
    Thank you so much, But I need it in one step only.

  8. #8
    Registered User
    Join Date
    06-16-2012
    Location
    london, england
    MS-Off Ver
    Excel 20101
    Posts
    11

    Re: Nearest one or two or three numbers in a row of data

    Quote Originally Posted by Cutter View Post
    How about an amendment to Martin's formula:

    =SUM(LARGE(A1:H1,COUNTIF(A1:H1,">=50")+{1,2,3}))
    I am trying it .... looks great.

  9. #9
    Registered User
    Join Date
    06-16-2012
    Location
    london, england
    MS-Off Ver
    Excel 20101
    Posts
    11

    Re: Nearest one or two or three numbers in a row of data

    The problem solved by Martin's Formula.

    =SUM(LARGE(A1:H1,{1,2,3}+COUNTIF(A1:H1,">=50")))


    Thank you Martin.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1