+ Reply to Thread
Results 1 to 6 of 6

How to sum X number of cells

  1. #1
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    How to sum X number of cells

    Hi everyone,

    I would really appreciate your help with the following as I have been stuck on this for a little while. Here is an overview of the layout:

    1. Cells A1 and B1 contain the titles of the columns A and B.

    2. In column A, the cells A2:A21 each contain a number ranging from 1 to 20. No two cells have the same number.

    3. In column B, the cells B2:B21 each have a different number value. There are no blank cells or cells containing letters.


    What I would like to have is as follows:

    1. A function set beneath column A that can automatically locate the number 15 in column A (in this example, this is cell A16), and then sum the values in the previous 5 cells of column B (in this case, it is SUM(B12:B16)).

    2. The sum value should then appear at the bottom of column B.

    I have attached a worksheet with the layout described above to make your lives easier. I look forward to your response.

    Many thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to sum X number of cells

    Hi.

    Slightly offbeat approach, but non-volatile, so perhaps even preferable to a construction using INDEX:INDEX (and certainly preferable to ones using OFFSET or INDIRECT):

    =SUM(INDEX(B2:B21,N(IF(1,MATCH(15,A2:A21,0)-{0,1,2,3,4}))))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

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

    Re: How to sum X number of cells

    See the attached file.

    The result is in the green cell.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: How to sum X number of cells

    Quote Originally Posted by XOR LX View Post
    Hi.

    Slightly offbeat approach, but non-volatile, so perhaps even preferable to a construction using INDEX:INDEX (and certainly preferable to ones using OFFSET or INDIRECT):

    =SUM(INDEX(B2:B21,N(IF(1,MATCH(15,A2:A21,0)-{0,1,2,3,4}))))

    Regards
    Hi XOR LX,

    That's magnificent, and just what I was looking for. Many thanks for your help!

  5. #5
    Registered User
    Join Date
    12-12-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: How to sum X number of cells

    Hi oeldere,

    Thanks very much for your quick response, it is a big help.

    All the best!

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to sum X number of cells

    You're welcome!

+ 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. Color a certain number of cells based on a number from a separate sheet.
    By keeblerelf in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-19-2013, 06:11 AM
  2. how to decrease one cells number while increasing another cells number
    By raffi123 in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 06-12-2013, 04:31 PM
  3. Replies: 0
    Last Post: 09-06-2012, 10:41 AM
  4. Replies: 4
    Last Post: 01-02-2007, 07:50 AM
  5. Count number of times a specific number is displayed in cells
    By subs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2005, 11:05 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