+ Reply to Thread
Results 1 to 3 of 3

Formula to calculate Sum for rolling last n cells in a row

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    california
    MS-Off Ver
    Excel 2011
    Posts
    2

    Formula to calculate Sum for rolling last n cells in a row

    Would someone be able to help me make a formula that will calculate the last n cells (in this case, I want n = 12) within the same row. I'd like it to be rolling, so that I can add future data/columns and have the total still calculate the last 12. There will not always be data, so some cells may have 0 or blank and I'd like it to still count that as a cell towards the n count, using a value of zero. I've attached a workbook example.

    For example using my attached sheet, row 3: I currently have data in columns B through N. I have the formula for the total in column O. I manually selected the last 12 cells to get the total that I have currently. But I'd like to replace that simple formula that will automatically select the last 12 columns, even if I had a new column before it. For example, right now I have summed up Feb-13 to Jan-14, but next month I will be adding in a new column in between Jan-14 and the total column, for Feb-14. I'd like the total, which would now get pushed to column P, to update the sum to be the new last 12 cells.

    And then I need the same thing done for column P: where i'm taking an "average" for the last 12 cells of data (from my months). I'd like it to be rolling average of last 12 cells. In this case however, I want it to ignore 0's and not apply it to the average.

    At first I was just using my simple sum formula, and then manually updating which cell it started with and then double clicking the formula to apply to the rest of the sheet: but I have some color formatting separating my customers data, so when i double click it only applies it down to the next customer data (because it sees the different style formatting) And if I drag down to the bottom, I lose my color formatting that highlights when each customer starts.

    Any help would be greatly appreciated!! Thanks.
    sample_rolling12month_count.xlsx

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Formula to calculate Sum for rolling last n cells in a row

    Using your posted workbook, try these regular formulas, copied down:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    california
    MS-Off Ver
    Excel 2011
    Posts
    2

    Re: Formula to calculate Sum for rolling last n cells in a row

    That was perfect, exactly what I was looking for! You are my hero. Thanks Ron!

+ 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. [SOLVED] How to calculate a rolling average over X periods
    By Johnex777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-03-2013, 10:37 AM
  2. How to calculate rolling time for a trip
    By mmslash in forum Excel General
    Replies: 2
    Last Post: 05-31-2012, 02:54 PM
  3. How to calculate 2 Rolling Averages?
    By TBT in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-02-2008, 06:34 AM
  4. Calculate Discrete Averages, not rolling
    By bkopeikin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-18-2007, 11:04 PM
  5. [SOLVED] calculate using rolling calendar
    By Martha in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2005, 05:05 PM

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