page27
Sub Calcula
Dim doc as Object
Dim plan as Object
Dim intervalo as Object
Dim media as double
Dim acumula as double
Dim desvio as double
doc = ThisComponent
plan = doc.Sheets(0)
intervalo = plan.getCellRangeByName("A1:A10")
for i = 0 to intervalo.getRows.getCount - 1
media = media + intervalo.getCellByPosition(0,i).value
Next
media = media / 10
for i = 0 to intervalo.getRows.getCount - 1
acumula = acumula + (intervalo.getCellByPosition(0,i).value - media) ^2
next
desvio = sqr(acumula / 9)
plan.getCellByPosition(0,10).value = media
plan.getCellByPosition(0,11).value = desvio
End sub
COMO FAZER | tutorial