+ Reply to Thread
Results 1 to 10 of 10

Function to Sum a number of rows based on a variable

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    5

    Post Function to Sum a number of rows based on a variable

    Hello!

    I've been searching for an answer to my question, but unfortunately I'm not sure exactly how to describe my problem so I have been unsuccessful with my search. If anyone could help me with this I would be very appreciative.

    As you can see in the attached excel doc, I have calculated a column for "Number of Claims Per week" and also "Dollar amount Per claim". This was done using VLOOKUP and distributions. That is not the issue.

    The issue I am having is creating the "TOTAL" for the week. So for example, if week one generates 4 claims, I need to be able to add up claim amount #1-#4.

    It seems as though this would be a basic function, but I can seem to find a way to add up a certain number of cells, based on a variable generated from a random number.

    If you take a look a my excel sheet, I am trying to solve for the "Claim Total" column on the far right. This column should be the sum of (Number of claims * The individual amount per claim). Note that if there is 4 claims in that week, I would have to add up claim 1-4 to get that weeks total.

    Greatly appreciate any help! Thanks.
    Attached Files Attached Files
    Last edited by mstew9415; 06-23-2014 at 08:16 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Basic Excel Funtion - HELP NEEDED!

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    5

    Re: Basic Excel Funtion - HELP NEEDED!

    Quote Originally Posted by Richard Buttrey View Post
    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    I fixed the title hopefully it is appropriate now. Are you able to help with this issue?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,930

    Re: Function to Sum a number of rows based on a variable

    Im not sure exactly which ranges you are looking at, but this is the syntax/function you would use...
    =SUMIF($J$14:$J$113,"<="&L3,$I$14:$I$113)

    adjust the ranges to what you need
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    06-23-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    5

    Re: Function to Sum a number of rows based on a variable

    Quote Originally Posted by FDibbins View Post
    Im not sure exactly which ranges you are looking at, but this is the syntax/function you would use...
    =SUMIF($J$14:$J$113,"<="&L3,$I$14:$I$113)

    adjust the ranges to what you need
    thanks for the reply. But im not sure SUMIF is the function I am looking for. I don't think it is a sum "based on a criteria".

    I wish I knew excel better so I could clearly express my problem.

    Lets say I have 10 rows, with the values: 1,1,1,1,1,1,1,1,1,1

    I have a random number generated which = 5. So lets say x=5.

    How do I add up the first x rows? In this case 5. (1+1+1+1+1)
    Last edited by mstew9415; 06-23-2014 at 08:36 PM.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,930

    Re: Function to Sum a number of rows based on a variable

    The way I structured that formula was to sum all data that had week's <= (in this case) 5

    Im not sure which columns you are refering to, and what a sample answer woud look like, so if you could provide that, it would help

  7. #7
    Registered User
    Join Date
    06-23-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    5

    Re: Function to Sum a number of rows based on a variable

    Quote Originally Posted by FDibbins View Post
    The way I structured that formula was to sum all data that had week's <= (in this case) 5

    Im not sure which columns you are refering to, and what a sample answer woud look like, so if you could provide that, it would help
    I've attached another excel file highlighting the relevant columns.

    So as you can see, there are a certain number of repair claims filed per week . In my case it is 2 claims for week one. (Left column cell B2).

    So now I need to find a way to add up the first 2 (number of claims) rows in the "Amount Per Claim" highlighted column. In my case it would be 2787.34 + 1756.23.

    I need to output this value, using a formula I would assume, into the third column highlighted on the right, calculating the total cost per week. The number of claims changes because it is generated using a random number, so the number of rows needed to be summed in the middle highlighted column changes.

    Hope that makes it more clear.

    Edit: Also, make sure you zoom out to about 90% or so in order to see the third highlighted column.
    Attached Files Attached Files

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Function to Sum a number of rows based on a variable

    Maybe something like this...

    Data Range
    A
    B
    C
    D
    1
    Data
    -----
    Number of cells
    Sum
    2
    1
    5
    5
    3
    1
    4
    1
    5
    1
    6
    1
    7
    1
    8
    1
    9
    1
    10
    1
    11
    1


    This formula entered in D2:

    =SUM(A2:INDEX(A2:A11,C2))

    If C2 is an empty cell the formula will sum the entire range.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    06-23-2014
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    5

    Re: Function to Sum a number of rows based on a variable

    Quote Originally Posted by Tony Valko View Post
    Maybe something like this...

    Data Range
    A
    B
    C
    D
    1
    Data
    -----
    Number of cells
    Sum
    2
    1
    5
    5
    3
    1
    4
    1
    5
    1
    6
    1
    7
    1
    8
    1
    9
    1
    10
    1
    11
    1


    This formula entered in D2:

    =SUM(A2:INDEX(A2:A11,C2))

    If C2 is an empty cell the formula will sum the entire range.

    Yes, this is what I was looking for! it seems to be working. Thank you and @FDibbins very much for the help. Reps

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Function to Sum a number of rows based on a variable

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ 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. Basic Macro needed
    By alanbenjy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-02-2010, 07:31 AM
  2. basic formula help needed
    By Malchemist in forum Excel General
    Replies: 2
    Last Post: 05-31-2010, 06:49 AM
  3. Basic IF function help needed
    By EME in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-29-2009, 05:51 AM
  4. Help needed learning basic excel vba
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2009, 04:27 AM
  5. Basic Excel Question - Help Needed
    By PepsiCo85 in forum Excel General
    Replies: 3
    Last Post: 07-23-2007, 09:01 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