Fix Excel VBA Cannot Evaluate Web Add-in Custom Functions Synchronously
Question details
Users need a way to reliably retrieve results from Excel Web Add-in custom functions via VBA without encountering premature evaluation errors.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Executing a VBA macro that relies on the immediate result of a Web Add-in custom function via Application.Evaluate or by reading a formula cell.
- Observed behavior
- Excel returns error codes such as 2015 or 2051 because the asynchronous Web Add-in has not finished calculating before VBA attempts to read the result.
Verify that your Web Add-in custom function calculates correctly in a standard Excel cell without VBA intervention before modifying your macro scripts.
Use Application.OnTime to Wait for Asynchronous Results
Delay your VBA execution using a polling routine to wait for the Web Add-in to finish calculating its asynchronous result.
Because Web Add-ins operate asynchronously to prevent Excel from freezing, VBA's synchronous Application.Evaluate will fail. Writing the formula to a cell and periodically checking its value is the most reliable workaround.
Modify your VBA script to write the Web Add-in custom function formula directly to a specific worksheet cell instead of evaluating it in memory.
Implement a controlled polling routine using Application.OnTime to check the target cell's value at set intervals (e.g., every 1-2 seconds).
Within the polling routine, add logic to check if the cell value contains an error code (such as Error 2015 or Error 2051). If it does, schedule another check.
Once the cell returns a valid, non-error calculated result, exit the polling loop and allow the rest of your VBA macro to execute.
Add a maximum iteration counter to your loop to act as a timeout, preventing infinite loops if the Web Add-in fails to calculate completely.

Migrate the Custom Function Logic Directly to VBA
If immediate synchronous results are strictly required, bypass the Web Add-in by rewriting the calculation logic as a native VBA function.
Experience Seamless Macro Execution with WPS Office
While Excel's Web Add-ins may introduce complex asynchronous evaluation challenges, WPS Office offers a highly compatible, lightweight alternative for handling your spreadsheets and macros with ease and efficiency.
- 1. Download and Install: Download WPS Office for free from the official website and follow the lightweight installation process.
- 2. Open Your Macro Workbook: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb files containing your VBA projects.
- 3. Enable Macros: Click 'Enable Macros' in the security warning prompt to seamlessly run your automated VBA scripts.

Frequently Asked Questions
What does VBA Error 2015 mean when calling a Web Add-in?
Error 2015 corresponds to the #VALUE! error in Excel. In the context of Web Add-ins, VBA returns this error when attempting to synchronously read a cell or evaluate a function that is still processing its asynchronous calculation.
Why does Application.Evaluate fail with Excel Web Add-ins?
Application.Evaluate executes synchronously and expects an immediate return value. Because Web Add-in custom functions are designed to run asynchronously (to prevent the Excel UI from freezing), they cannot return a value fast enough for Application.Evaluate, resulting in an error.
Can I force a Web Add-in custom function to run synchronously?
No, Excel's modern Web Add-in architecture enforces asynchronous execution for custom functions. You must handle the delay programmatically using events or polling methods like Application.OnTime.




