+ Reply to Thread
Results 1 to 4 of 4

Automatically changing references to last 12 values when new value is added

  1. #1
    Registered User
    Join Date
    06-23-2009
    Location
    Berkeley, CA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Automatically changing references to last 12 values when new value is added

    I have a chart that sums up the last 12 months of data. At the end of each new month, a new row of data is added and the last row is taken out of accounting (though is not deleted). Right now I'm manually changing the summation argument to sum the last 12 months of data. Is there a macro or formula I could write for the chart, which would switch down each time a new value is added? (For example, once a month elapses, going from A1:A12 to A2:A13). Thanks for any insight!

    - IT

  2. #2
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Automatically changing references to last 12 values when new value is added

    Try this formula:

    Please Login or Register  to view this content.
    I'm assuming that you've a single cell in which the running total is displayed- the formula above should sum the most recent 12 values. It also requires that you've at least 12 entries to total- less than that and it will probably generate an error.
    Last edited by deadlyduck; 06-23-2009 at 05:56 PM.
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Automatically changing references to last 12 values when new value is added

    Assuming no blanks interspersed amongst values...first value in Row 1

    Using INDEX (non-Volatile)

    =SUM(INDEX(A:A,MAX(1,COUNT(A:A)-11)):INDEX(A:A,MAX(12,COUNT(A:A))))

    Using OFFSET (Volatile like INDIRECT)

    =SUM(OFFSET(A1,MAX(0,COUNT(A:A)-12),,12,1))

    both should handle any number of values in A (ie above / below 12)

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Automatically changing references to last 12 values when new value is added

    hi Itregub,

    You have been given a couple of solutions already but here are some links to Jon Peltier's site which may give you even more ideas of what's possible:
    http://peltiertech.com/Excel/Charts/DynamicLast12.html
    from
    http://peltiertech.com/Excel/Charts/Dynamics.html
    or for even more possibilities check out his other pages:
    http://peltiertech.com/Excel/Charts/index.html

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

+ 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