Macro for moving average and charting

sramalin

New Member
Joined
Jun 13, 2011
Messages
2
I have the following in my file,

Sheet 1 is a typical output consisting of five columns (A,B,C,D,E) that I get from my experiment. For my data analysis then, I do a two point moving average ( in Sheet 2) and three point moving average (in Sheet 3) of all the columns in Sheet 1 and plot a graph that consists of two series (i.e. Col B (X) vs Col C (Y) and Col D (X) vs Col E (Y) ). The formula for two and three point average that i use are

Two point moving average: =AVERAGE(INDIRECT("Sheet1!A"&(ROW(A4)-1)*2+1&":A"&(ROW(A4)-1)*2+2))

Three point moving average: =AVERAGE(INDIRECT("Sheet1!A"&(ROW(A4)-1)*3+1&":A"&(ROW(A4)-1)*3+3))


I have hundreds of files like this and inorder to save time and automate the processing I tried recording a macro to do the task for me. But then I encountered many errors and coming from a non-programming background I had no clue what was going on.

Can someone please help me with this. Can a macro be written that can perform this? Any help is greatly appreciated.

Much thanks,

Karthik
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
And just to clarify, this moving average also reduces the amount of data I have. That is a two point moving average of col A would be

B1 = (A1+A2)/2
B2 = (A3+A4)/2 and so on so forth.

Similarly a three point moving average would be B1 = (A1+A2+A3)/3, B2= (A4+A5+A6)/3 etc.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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