View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jeff Harbin[_2_] Jeff Harbin[_2_] is offline
external usenet poster
 
Posts: 16
Default Calculating Averages in VBA...

I've got a calculation that I need to compute that includes the average and
the standard deviation of a group of numbers. The group of numbers will
vary in size from one instance to another so I want to programmically
calculate the values.

In the past I've written code that places the values of the Average and
Standard Deviation into cells on a separate worksheet and then reference
those cells in my VBA code....

////Example////
Dim DataRange as String

Worksheets("Sheet1").Range("A1").Formula = "=Average(DataRange)"
Worksheets("Sheet1").Range("A2").Formula = "=StDev(DataRange)"

......

to divide the standard deviation by the average, I'd write code similar
to....

Worksheets("Sheet1").Range("A2").Value/Worksheets("Sheet1").Range("A1").Valu
e

/////End Code//////

Can I do this without populating worksheet cells with the Average and
Standard Deviation directly in VBA?

Thanks,

Jeff