Showing posts with label worksheet functions. Show all posts
Showing posts with label worksheet functions. Show all posts

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