Sum cells dynamically based on Date

anonemous

New Member
Joined
Dec 2, 2015
Messages
16
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
  2. MacOS
I have a worksheet where each month, a new column is inserted to the front with the past month's worth of data.
There are two separate columns to output Year to Date sums along with the change in percentage, which would be Jan-March 2020 compared with Jan-March 2019 and the change. (highlighted in red below)

B2 = SUM(E2:G2)
C2 = SUM(Q2:S2)
D2 = (c2-b2)/b2

How can I modify these columns so that they will do it automatically each month instead of having to revise my formula each month?
I've found that sometimes I might make mistakes and not realize the YTD is summing the wrong month.
Previously I've found that I can use INDIRECT to keep cells static, but this doesn't work when each month is dynamic in a YTD format.

mrexcel_04082020.jpg


Advice always appreciated from here!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Please post the Excel Sheet.
Please let me know if new month is updated will be updated in "E" colomn
 
Upvote 0
Posted below, as mentioned each month there will be a new month in the E column..
e.x.:
At the end of this month, E will be "April 2020". Column B, C, D will be (sum of jan-april 2020)-(sum of jan-april 2019)/(sum of jan-april 2019)
End of May, E will be "May 2020", Column B, C, D will be (sum of jan-may 2020)-(sum of jan-may 2019)/(sum of jan-may 2019)


sheet.xlsx
ABCDEFGHIJKLMNOPQRS
1DataYTD TTLpYTD TTLPCT %Mar-20Feb-20Jan-20DecNovOctSepAugJulJunMayAprMarFebJan-19
2Data 1642600%123456789101112131415
3Data 2918100%3334567891098765
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=SUM(E2:G2)
C2:C3C2=SUM(Q2:S2)
D2:D3D2=IFERROR(((C2-B2)/B2),"-%")
 
Upvote 0
Give this a try

20 04 10.xlsm
ABCDEFGHIJKLMNOPQRS
1DataYTD TTLpYTD TTLPCT %Mar-20Feb-20Jan-20Dec-19Nov-19Oct-19Sep-19Aug-19Jul-19Jun-19May-19Apr-19Mar-19Feb-19Jan-19
2Data 1642600%123456789101112131415
3Data 2918100%3334567891098765
YTD
Cell Formulas
RangeFormula
B2:B3B2=SUM(OFFSET(D2,,1,,MONTH(OFFSET(D$1,,1))))
C2:C3C2=SUM(OFFSET(D2,,13,,MONTH(OFFSET(D$1,,1))))
D2:D3D2=IFERROR(((C2-B2)/B2),"-%")
 
Last edited:
Upvote 0
The suggestions in my previous post use the volatile function OFFSET. If that has an impact on your sheet's performance, here is a non-volatile way to get the sums.

20 04 10.xlsm
ABCDEFGHIJKLMNOPQRS
1DataYTD TTLpYTD TTLPCT %Mar-20Feb-20Jan-20Dec-19Nov-19Oct-19Sep-19Aug-19Jul-19Jun-19May-19Apr-19Mar-19Feb-19Jan-19
2Data 1642600%123456789101112131415
3Data 2918100%3334567891098765
YTD (2)
Cell Formulas
RangeFormula
B2:B3B2=SUM(INDEX(D2:S2,2):INDEX(D2:S2,1+MONTH(INDEX(D$1:S$1,2))))
C2:C3C2=SUM(INDEX(D2:S2,14):S2)
D2:D3D2=IFERROR(((C2-B2)/B2),"-%")
 
Upvote 0
Cheers, thanks Peter! Offset formula and the alternative one have both worked. Already using it and grinning from saving time. Thanks again !
 
Upvote 0
You're welcome. Glad to help. Thanks for the follow-up. :)
 
Upvote 0
I'm trying to solve a similar issue but my months are in order: 1/1/2020 | 2/1/2020 | 3/1/2020 | .... YTD 2020

I've tried a few things but nothing successful.... how would I be able to leverage the above?

THANKS!
Mark
 
Upvote 0
how would I be able to leverage the above?
Can you post a small set of sample data and expected results (manually entered) with XL2BB so that we can be sure of your layout, data and requirements?

Also, please update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I've updated my environment (sorry about that). I can't seem to add the add-in as this is a company pc and they lock it down pretty well so I've pasted the information below.

LocationJan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-192019 Total Jan-20Feb-20Mar-20Apr-20May-20Jun-20
Location 1
46,049​
43,748​
44,348​
42,880​
39,920​
36,567​
35,545​
42,483​
35,709​
38,270​
31,956​
28,725​
466,200 42,070 32,563
31,683​
Location 2
11,647​
10,511​
12,659​
13,599​
12,521​
60,937
Location 3
56,005​
55,037​
67,210​
48,630​
65,952​
51,203​
55,902​
47,710​
49,093​
50,496​
52,537​
25,190​
624,965 51,556 49,796
55,623​
Location 4
55,596​
50,597​
57,131​
52,710​
53,237​
59,279​
57,239​
51,856​
50,203​
58,444​
54,478​
13,473​
614,243 12,363 54,539
52,832​
Location 5
13,014​
13,187​
11,846​
13,481​
14,766​
13,506​
13,626​
13,420​
13,374​
13,879​
13,410​
11,232​
158,741 13,077 11,036
13,998​
Location 6
37,082​
35,820​
39,178​
28,416​
34,402​
25,363​
36,662​
40,073​
37,379​
43,015​
35,491​
26,095​
418,976 35,764 29,549
33,102​

The expected outcome based on a date update:


3/1/2020​
Current
Year YTD
Prior Year
Location 1 106,316
134,145​
Location 2 -
34,817​
Location3 156,975
178,252​
Location 4 119,734
163,324​
Location 5 38,111
38,047​
Location 6 98,415
112,080​

Sorry It's not in the greatest format!
Mark
 
Upvote 0

Forum statistics

Threads
1,215,407
Messages
6,124,723
Members
449,184
Latest member
COrmerod

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top