'Why is WorksheetFunction.Rank_Eq not working?

I've highlighted the line in the code that isn't working. S appears to be a well-defined array populated with numbers.

What am I doing wrong?

Function Payouts(StartValue, Vol, CholDecomp)

Dim TrialCounter As Integer
Dim TickerCounter As Integer
Dim BetCounter As Integer
Dim Results As Variant
ReDim Results(1 To 14, 1 To 6) As Double
Dim ZUncorr As Variant
ReDim ZUncorr(1 To 14) As Double
Dim ZCorr As Variant
ReDim ZCorr(1 To 14) As Double
Dim S As Variant
ReDim S(1 To 14) As Double
Dim Ranking As Variant
ReDim Ranking(1 To 14) As Double



For TrialCounter = 1 To 1
    For TickerCounter = 1 To 14
        ZUncorr(TickerCounter) = WorksheetFunction.NormSInv(Rnd)
    Next TickerCounter
    ZCorr = WorksheetFunction.Transpose(WorksheetFunction.MMult(CholDecomp, WorksheetFunction.Transpose(ZUncorr)))
    For TickerCounter = 1 To 14
        S(TickerCounter) = StartValue(TickerCounter) * Exp(ZCorr(TickerCounter) * Vol(TickerCounter) - Vol(TickerCounter) ^ 2 / 2)
    Next TickerCounter
    For TickerCounter = 1 To 14
        ' error is on next line
        Ranking(TickerCounter) = WorksheetFunction.Rank_Eq(S(TickerCounter), S)
    Next TickerCounter
    
Next TrialCounter

Payouts = S

End Function


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source