+ Reply to Thread
Results 1 to 9 of 9

Sum of middle three figures

  1. #1
    Registered User
    Join Date
    06-23-2017
    Location
    Fort Collins, CO
    MS-Off Ver
    Office 2010
    Posts
    29

    Sum of middle three figures

    Can this be done?

    I will have a column consisting of 3, 5, or 7 entries. Regardless of the number entries I want a sum of the middle three values.

    EG.
    1, 2, 3 = 6 (1+2+3)
    1, 2, 3, 4, 5 = 8 (2+3+4)
    1, 2, 3, 4, 5, 6, 7 = 12 (3+4+5)

    Is there a formula that can do this?

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Sum of middle three figures

    Here's one option:

    =SUM(IF(COUNT(A1:A7)=3,A1:A3,IF(COUNT(A1:A7)=5,A2:A4,IF(COUNT(A1:A7)=7,A3:A5))))

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Sum of middle three figures

    A little shorter:

    =SUM(CHOOSE((COUNT(A1:A7)-3)/2+1,A1:A3,A2:A4,A3:A5))

  4. #4
    Registered User
    Join Date
    06-23-2017
    Location
    Fort Collins, CO
    MS-Off Ver
    Office 2010
    Posts
    29

    Re: Sum of middle three figures

    That option would work if the numbers were always in order from least to greatest, but that won't be case. For reference what I have is the results of judges scores for different athletes. The rows are set to a specific judge and columns set to an athlete. Where there are 5 judges I drop the high and low and sum the middle 3. For 7 judges, drop the 2 highest and 2 lowest and add the middle three. Also the middle 3 scores might be exactly the same or all different. I should have explained that in the beginning.

  5. #5
    Registered User
    Join Date
    02-13-2015
    Location
    Boston, MA
    MS-Off Ver
    2013
    Posts
    10

    Re: Sum of middle three figures

    I'm sure there's a better way to code this but this will work for you.

    =IF(COUNT(A1:A7)=5,
    SUM(A1:A7)-SMALL(A1:A7,1)-LARGE(A1:A7,1),
    SUM(A1:A7)-SMALL(A1:A7,1)-SMALL(A1:A7,2)-LARGE(A1:A7,1)-LARGE(A1:A7,2))

    This will return an incorrect amount if you only register 6 scores, you can avoid that by adding a second if statement to create a custom return for that.

  6. #6
    Registered User
    Join Date
    06-23-2017
    Location
    Fort Collins, CO
    MS-Off Ver
    Office 2010
    Posts
    29

    Re: Sum of middle three figures

    Thank you mjo1983. That's what I needed.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Sum of middle three figures

    Does the formula from post #5 work for instances when there are only 3 numbers?

    This works for 3, 5, and 7:

    =SUM(A1:A7,CHOOSE((COUNT(A1:A7)-3)/2+1,0,-MIN(A1:A7)-MAX(A1:A7),-SMALL(A1:A7,{1,2})-LARGE(A1:A7,{1,2})))
    Last edited by 63falcondude; 10-05-2018 at 12:12 PM.

  8. #8
    Registered User
    Join Date
    06-23-2017
    Location
    Fort Collins, CO
    MS-Off Ver
    Office 2010
    Posts
    29

    Re: Sum of middle three figures

    I took the basic form from #5 and added more IF statements. What I really needed to learn from the question was the existence of the max/min, small/large functions. Once I had that I could make it fit my exact needs. My code is clumsy and cumbersome but it works. The short sweet code you posted would have been better.

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Sum of middle three figures

    How about

    =SUM(SMALL(A1:A7,INT(COUNT(A1:A7)/2)+{0,1,2}))

    Which will work with 3, 5, 7, or more numbers if you want a bigger range.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 12-17-2015, 06:26 PM
  2. Replies: 3
    Last Post: 02-17-2015, 05:16 PM
  3. [SOLVED] How to convert First, Middle, Last name to Last, First Middle Initial with VBA
    By lwine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2013, 03:33 PM
  4. Conversion of an array of figures inputted into cells as word figures to Excel figures
    By Allan Simpson730 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-08-2013, 07:25 AM
  5. Extracting the Middle Initial/Middle Name
    By akwishestofish in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-16-2012, 11:13 AM
  6. [SOLVED] Applying figures and sums of figures to relevent cells
    By JakeMann in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2012, 10:08 AM
  7. Average on the 6 latest figures of a list where figures keep being added
    By patounet527 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-27-2009, 06:02 AM

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