The mother of all objects is Excel itself. We call it the Application object. The application object gives access to a lot of Excel related options.
Worksheet Function
You can access almost any Excel function through the Application object.
Range("A3").Value = Application.WorksheetFunction.Average(Range("A1:A2"))
When you click the command button on the worksheet, Excel VBA calculates the average of the values in Cell A1 and Cell A2 and places the result into cell A3.
Note: instead of Application.WorksheetFunction.Average, you can also just use WorksheetFunction.Average.
There are many more worksheet functions you can use in Excel VBA. Want to see more?
1. Launch the Visual Basic Editor.
2. Type in: worksheetfunction.
3. A list will appear showing you all the worksheet functions available.
No comments:
Post a Comment