0

I currently have a daily report at work where I have to obtain the standard deviation of the last cell and its 364 previous observations. However, I would like to find a way to do it by VBA.

I would really appreciate any advice you could give me.

So far, I have tried the following code (I am new to VBA so please excuse me if it is a really easy question):

Sheets("Hoja1").Select
lastvalue=Range("A1").End(xlDown).Select
Cells (2,4)=Application.WorksheetFunction.StDev(Application.WorksheetFunction.Offset(lastvalue,0,0,-365))
braX
  • 11,506
  • 5
  • 20
  • 33
sebasmps
  • 1
  • 1

1 Answers1

0

Assuming you have at least 356 rows of data....

Dim rng As Range

With Sheets("Hoja1")
    Set rng = .cells(.rows.count, 1).end(xlUp).Offset(-364,0).Resize(365, 1)
    .Cells(2, 4).Value = Application.StDev(rng)
End With
Tim Williams
  • 154,628
  • 8
  • 97
  • 125