I am trying to select those values from a one-dimensional range of data that fall below the average. Also, I am trying to count how many of them there are, and finally, to calculate the variance.
This code doesn't seem to be working and I think the problem comes when I populate the array :/
This code doesn't seem to be working and I think the problem comes when I populate the array :/
Code:
Function MoyBelow(data As Range) As Variant
Dim i As Integer
Dim N As Long
Redim BelowAvg() As Variant
Dim Varian As Double
Dim Somcar() As Variant
N=WorksheetFunction.Average(data)
RendMoy=WorksheetFunction.Average(data)
For i=1 To N
If data.Cells(i).Value < RendMoy Then
BelowAvg(i).Value = data(i).Value
End If
NB = BelowAvg.Count
For j=1 To NB
SumSq= SumSq + (BelowAvg(i) - RendMoy)^2
Next i
Varian = Somcar/NB
End Function
Last edited: