Macros to create moving standard deviation calculation

ewibolo

New Member
Joined
May 16, 2011
Messages
7
Excel 2007

Hi, I am trying to use Macros to calculate the standard deviation of the last 5 cells I input for example:

<table width="44" border="0" cellpadding="0" cellspacing="0" height="207"><colgroup><col style="width:51pt" width="68"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">1356</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">4530</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">4450</td> </tr> <tr style="height:15.75pt" height="21"> <td class="xl64" style="height:15.75pt;width:51pt" width="68" height="21">5300</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">2960</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">4300</td> </tr> <tr style="mso-height-source:userset;height:15.75pt" height="21"> <td class="xl64" style="height:15.75pt;width:51pt" width="68" height="21">4530</td> </tr> <tr style="mso-height-source:userset;height:18.75pt" height="25"> <td class="xl64" style="height:18.75pt;width:51pt" width="68" height="25">5450</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">1300</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl64" style="height:15.0pt;width:51pt" width="68" height="20">2960</td> </tr> </tbody></table>
I will be adding more cells to the bottom of this list very often, and I would like to use macros to automatically calculate the standard deviation of the last 5 values.

Thanks for your help in advance!

Ewi
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the board. How about just a formula?

=STDEV(INDEX(A:A, MATCH(9E+307, A:A)):INDEX(A:A, MATCH(9E+307, A:A)-4))
 
Upvote 0
Holy Mackerel! Thanks very much!

Have a nice day,

Eric

P.S. - thanks for the warm welcome
 
Last edited:
Upvote 0
how about if I have a column broken into sections (ex.- 100 rows divided into 25)

A1-A25
A26-A50
A50-A75
A75-A100

I am constantly updating each section by adding one or two entries per day to each section.

That formula works perfectly,but if I only have 1 type of item and am using the entire column for the calculation.

How about if I have one column broken up into 4 different sections and would like to calculate the standard deviation for each of the 4 sections in that column?

Don't let the evenly divided sections mislead you.....they are all different in my spreadsheet. One column may have 35 entries, the other may have 27, 14, etc. I update and add them individually and not evenly, so that the next day I might have 38 entries,27,15, etc.


Thanks for the help!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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