Weighted Average. Runtime Error: Index out of defined Range.

asked 2019-09-06 18:07:08 +0200

JackZed gravatar image

updated 2019-09-06 18:14:41 +0200

Function Weighted_Average(optional x(), optional w()) dim WA as double dim SUMWX as double dim SUM as double

        For i = 1 to UBound(x)
            SUMWX = SUMWX + w(i,1)*x(i,1)
        Next i

        For b = 1 to UBound(x)
            SUM = SUM + w(i,1)
        Next b

        WA = SUMWX/SUM
        Weighted_Average = WA

    End Function
edit retag flag offensive close merge delete


Please reformat into something more readable, tell us how you call that and ask a question.

Opaque gravatar imageOpaque ( 2019-09-06 18:54:25 +0200 )edit