Creating macro for slightly complicated formula

  • Thread starter Thread starter CNN
  • Start date Start date
C

CNN

I'm really new to the whole macro business so I really need help. I'm trying
to create a macro to solve this equation

D =(Sum from 1 to Nt ((X - Xmean)^2/Nt))^0.5 ......I hope it's clear. I
don't know hope to format here.

Anyway, I have a range of Xs that are Nt in number and Nt is unknown so it
will have to be found first and this has to be in the code. I'm trying to
avoid having another column containing the values of (X - Xt)^2/Nt. I just
want D to be displayed in a designated cell, like F2. This code will be used
for multiple workbooks, all the data always on sheet 1 and Nt always a
different value. All the ways I could think of involved having the extra
column.

I would really appreciate any help. All I have so far is

Sub Macro2()

Dim LR As Long
Dim Mean
Dim Total
Dim i As Long


LR = .Range("A" & .Rows.Count).End(xlUp).Row
Mean = Average("A2:LR")
Total = 0

For i = 2 To LR

and I don't even understand the principle behind the LR code.

Thank you and sorry if I was long winded.
 
Hello,

Why do you want to code this?

There are built-in worksheet functions to calculate the standard
deviation in Excel, for example STDEV and STDEVP.

See the Excel help on those for more details.

But if you still need to do it on your own,
http://sulprobil.com/html/statistics_for_weighted_values.html
might give you a hint (look at the STDEV part of the macro - your
question would be answered if all weights are set to 1).

Regards,
Bernd
 
Back
Top