View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jerry W. Lewis Jerry W. Lewis is offline
external usenet poster
 
Posts: 837
Default STDEV function in VB scritp for excel

Your code produces errors because it does the equivalent of using
=STDEV("D5:D6")
instead of
=STDEV(D5:D6)
The arguments to STDEV must be numbers, arrays, or ranges, not strings. Try
StDev(Range("D" & Srow & ":D" & Erow - 1))
with either Application or WorksheetFunction as the prefix. Excel 2002
supports both prefixes, but WorksheetFunction has advantages so long as you
do not need the code to run in old versions of Excel.

Jerry

"dbwells" wrote:


Yes VBA Supplied with Excel
Excel 2002 sp3
application.stdev() does work.
Sheets("Sheet1").Cells(Nrow, 3).Value = Application.StDev("D" & Srow & ":D"
& Erow - 1)

Nrow is the row number of the summary worksheet.
Srow is the starting row of the number group.
Erow - 1 is the end row of the number group.
Erow is the row number of the next number group.

I now get a #VALUE! on the summary worksheet but this is a lot further than
I was getting before.

thanks for your help.