Friday, June 17, 2016

Three ways to use Excel worksheet functions in VBA



Function xlAverage01(rng)
    xlAverage01 = WorksheetFunction.Average(rng)
End Function

Function xlAverage02(rng)
    With WorksheetFunction
        xlAverage02 = .Average(rng)
    End With
End Function

Function xlAverage03(rng)
    Dim wsf As WorksheetFunction
    Set wsf = WorksheetFunction
    xlAverage03 = wsf.Average(rng)
End Function

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.