Google-sheets – SUM weekly values according to date in one column A and values in column B

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-datestracking

As shown in the screenshot, I have values I am looking to add for weekly totals to track, however, this is very tedious having to create a new code for every week, especially as the weeks change per month and so on. What I am looking to do is use the date feature as I have lined up in column A to match with column b and so on to make weekly values so I only have to type in the sum of a week number rather than a sum of ex b2:b8

I was thinking because if I were to type =ISOWEEKNUM("July 1") it gives me 27, so I am looking to use some code to say =SUM(week27in column a, B:B) type of thing but I don't know Google Sheets code well enough to think of it on my own.

If anyone has ideas please let me know.

enter image description here

Best Answer

Delete range A2:A and paste this into A2 cell and for next month just type August in A1 cell:

=ARRAYFORMULA(TEXT({ROW(INDIRECT("A"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 1))&":"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 7))));   "Week 1"; ROW(INDIRECT("A"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 8))&":"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 14))));  "Week 2"; ROW(INDIRECT("A"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 15))&":"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 21))));  "Week 3"; ROW(INDIRECT("A"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 22))&":"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 28))));  "Week 4"; ROW(INDIRECT("A"&
 DATEVALUE(DATE(2019, MONTH(A1&1), 29))&":"&
 DATEVALUE(DATE(2019, MONTH(A1&1), DAY(
 EOMONTH(DATE(2019, MONTH(A1&1),1),0)))))); "Week 5"}, "mmmm d"))

enter image description here