From: Elton Law on
Dear Expert,

Want to calculate Moving Average in this format.
But Sum is conditional

Say B2 to G2 are dates like this.
Say B3 to G3 are the prices.
A3 is Stock name
A2 is empty


Can you advise how to make it ...?
If I put a 3 in B1 ... Then it can calculate the 3-day moving average in C1.
If I put a 7 in D1 ... then it can calculate the 7-day moving average in E1

Moving average is dependent on the cell address to work out.
I have asked similar question before ... but the date is in vertical format.
This time .... If I present in horizontal format ... hope expert can still
make it ....
Thanks

21-Mar 22-Mar 23-Mar 24-Mar 25-Mar 26-Mar
Stock Name 1.7 1.6 1.75 1.63 1.77 1.42