We can access almost any Excel function through the Application object.
1. For example, place a command button on your worksheet and add the following code line:
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.
instead of
Application.WorksheetFunction.Average
we can also use
WorksheetFunction.Average
1. For example, place a command button on your worksheet and add the following code line:
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.
instead of
Application.WorksheetFunction.Average
we can also use
WorksheetFunction.Average
There are many more worksheet functions you can use in Excel VBA.
1. Launch the Visual Basic Editor
2. Type in: worksheetfunction
3. A list will appear showing you all the worksheet functions available
You can find many worksheet functions and make proper use on them as and when needed, while writing codes.
Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
ReplyDeleteexcel vba courses london