code for Average and Standadr deviation for certain values in excel 2010

farhan89

New Member
Joined
May 2, 2014
Messages
12
Hey ppl,

I am new to developer option or excel coding , I am writing a short code to calculate Average and Standard deviation of certain values, Since I need to update file daily so I think I need to store this code in some other excel file to run it and update the values or if I can store the code in excel and run on my file then please tell me .


[TABLE="width: 500"]
<tbody>[TR]
[TD]S[/TD]
[TD]N[/TD]
[TD]M[/TD]
[TD]A[/TD]
[TD]Std[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]First[/TD]
[TD]101[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]First[/TD]
[TD]105[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]First[/TD]
[TD]109[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]First[/TD]
[TD]200[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]First[/TD]
[TD]209[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]First[/TD]
[TD]220[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]First[/TD]
[TD]221[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]First[/TD]
[TD]290[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]First[/TD]
[TD]293[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]First[/TD]
[TD]291[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Second[/TD]
[TD]30[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Second[/TD]
[TD]39[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Second[/TD]
[TD]38[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Second[/TD]
[TD]34[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Second[/TD]
[TD]35[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Second[/TD]
[TD]36[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Second[/TD]
[TD]33[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Second[/TD]
[TD]40[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Second[/TD]
[TD]42[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Second[/TD]
[TD]41[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

This is how my Sheet look, Each 'N' has 5 'S' it will be in increment order and max 'S' can be 25 . For each N I want to calculate average and Standard Deviation for the similar S (eg Average and Standard deviation of all 1's M then Average standard deviation of all 2's M). Can anyone give me hint to do that , Where should I start ?
The filename is always "FILE.xlsx" and Sheet name is "NEW" .

Thanks

P.S: sorry for the bad explanation
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Putting your table in A1:E21 these formulas will work. You can then incorporate into macro if required.

For average:

=AVERAGEIFS($C$2:$C$21,$A$2:$A$21,A2,$B$2:$B$21,B2)

For standard deviation:

=STDEV(IF($A$2:$A$21=A2,IF($B$2:$B$21=B2,$C$2:$C$21)))

This one must be entered CNTL-SHIFT-ENTER
 
Upvote 0
You could also use a pivot table:


Excel 2010
ABCDEFG
1SNMRow LabelsAverage of MStdDev of M2
21First1011
31First105First144.854.66443085
41First109Second35.23.563705936
51First2002
61First209First26338.81365739
72First2203
82First221Second38.43.78153408
92First290
102First293
112First291
121Second30
131Second39
141Second38
151Second34
161Second35
173Second36
183Second33
193Second40
203Second42
213Second41
Sheet1
 
Upvote 0

Forum statistics

Threads
1,225,852
Messages
6,187,391
Members
453,424
Latest member
rickysuwadi

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