I'd like to create a macro that calculates a 20 day moving average. Within the attached spreadsheet, I'm referring to column C which calculates a 20 day average of column B's orders per day. It starts over each 20 days/rows. The manual calculations in the attachment is fine for this output, but we plan to run this numerous times throughout the year with YTD data and will need a macro to run the calculations.
I understand how to write the macro to average of the first 20 days, but can't figure out how to calculate the next set (per day).
For example:
Up to the 20th day, the formula calculates all orders and divides by 20, like =SUM(B2:B21)/20. When the "21st day" comes, we only want to calculate the previous 20 days so the range needs to skip to =SUM(B3:B22)/20 and so on.
Any help is appreciated!
I understand how to write the macro to average of the first 20 days, but can't figure out how to calculate the next set (per day).
For example:
Up to the 20th day, the formula calculates all orders and divides by 20, like =SUM(B2:B21)/20. When the "21st day" comes, we only want to calculate the previous 20 days so the range needs to skip to =SUM(B3:B22)/20 and so on.
Any help is appreciated!