|
|
Title | Make VBA code call a worksheet function |
Description | This example shows how to make VBA code call a worksheet function. |
Keywords | VBA, excel, worksheet function, STDEV |
Categories | Office |
|
|
The following VBA function isin a standard code module. It uses Application.WorksheetFunction to call the StdDev worksheet function.
|
|
Public Function MyStdev(ByVal stdev_range As Range)
' Call the worksheet function.
MyStdev = _
Application.WorksheetFunction.StDev(stdev_range)
End Function
|
|
The following cell content calls the VBA function. Another cell on the worksheet calls StDev directly so you can compare the results.
|
|
=mystdev(B2:B6)
|
|
|
|
|
|