How to Call Excel Worksheet Functions from VBA
Question details
The user wants to know how to call built-in Excel worksheet functions, specifically ROUNDDOWN, from within a VBA user-defined function or macro.
- Product
- Microsoft Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Writing a VBA macro or user-defined function that requires calculating values using standard worksheet formulas.
- Observed behavior
- The goal is to seamlessly utilize existing worksheet functions directly within the VBA object model.
Ensure that the Developer tab is enabled in your spreadsheet application and that you are familiar with accessing the VBA Editor using the ALT + F11 shortcut.
Use the Application.WorksheetFunction Property
This is the standard and most robust method for calling built-in worksheet functions within VBA.
The WorksheetFunction property acts as a container for most of Excel's standard formulas, making them accessible to your VBA macros.
Press ALT + F11 on your keyboard to launch the Visual Basic for Applications editor.
From the Project Explorer pane on the left, double-click the Module where you want to add your code, or insert a new one via Insert > Module.
Type the code to call the function. For example: `result = Application.WorksheetFunction.RoundDown(number, num_digits)`. Replace 'number' and 'num_digits' with your actual variables or numerical values.
Use the Application Object Shorthand
A quicker syntax alternative that omits the WorksheetFunction property, often used by developers for different error-handling behaviors.
Run VBA Macros Seamlessly in WPS Office
WPS Spreadsheet offers robust support for VBA macros, allowing you to use the exact same Application.WorksheetFunction syntax to call built-in functions as you would in Microsoft Excel.
- 1. Download and Install: Get WPS Office from the official website and complete the quick installation process.
- 2. Open Your Workbook: Launch WPS Spreadsheet and open your existing macro-enabled workbook (.xlsm).
- 3. Open the VBA Editor: Go to the Developer tab on the ribbon and click on the 'VBA Editor' icon to access your code environment.
- 4. Run Your Code: Execute your macros containing `Application.WorksheetFunction` calls directly without needing to rewrite or modify your existing scripts.

Frequently Asked Questions
Can I call every Excel worksheet function in VBA?
Most built-in worksheet functions can be called using Application.WorksheetFunction. However, functions that already have a native VBA equivalent (such as LEFT, RIGHT, or mathematical operators) might not be available in the WorksheetFunction object, as you are expected to use the native VBA functions instead.
What is the difference between Application.WorksheetFunction and Application?
The main difference lies in error handling. If a function called via Application.WorksheetFunction fails, it generates a VBA run-time error that must be handled with standard error trapping (e.g., On Error GoTo). Calling the function directly via the Application object returns an error value that you can test using the IsError() function.
Why doesn't IntelliSense show the function I want to use?
IntelliSense only displays functions officially supported by the VBA object model when using Application.WorksheetFunction. If you use the Application shorthand, IntelliSense may not list the worksheet functions, even though they will still execute correctly when you run the macro.




