logo
search
VBA & Macro Problems

Fix Excel VBA Cannot Evaluate Web Add-in Custom Functions Synchronously

Muhammad TalhaMuhammad Talha Sep 27, 2026 869 views

Question details

Users need a way to reliably retrieve results from Excel Web Add-in custom functions via VBA without encountering premature evaluation errors.

How to Fix Excel VBA Synchronous Evaluation Errors with Web Add-in Custom Functions
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.
Before you start

Verify that your Web Add-in custom function calculates correctly in a standard Excel cell without VBA intervention before modifying your macro scripts.

Solution 1Recommended

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.

1
Write the formula to a cell

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.

2
Set up a polling loop

Implement a controlled polling routine using Application.OnTime to check the target cell's value at set intervals (e.g., every 1-2 seconds).

3
Check for error values

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.

4
Proceed with execution

Once the cell returns a valid, non-error calculated result, exit the polling loop and allow the rest of your VBA macro to execute.

5
Implement a timeout

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.

Use Application.OnTime to Wait for Asynchronous Results
Important: Avoid using Application.Wait or Sleep API calls, as these will freeze Excel's main thread and prevent the Web Add-in from completing its calculation.
Free Microsoft Office alternative

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. 1. Download and Install: Download WPS Office for free from the official website and follow the lightweight installation process.
  2. 2. Open Your Macro Workbook: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb files containing your VBA projects.
  3. 3. Enable Macros: Click 'Enable Macros' in the security warning prompt to seamlessly run your automated VBA scripts.
Highly compatible with Microsoft Excel formats (.xlsx, .xls, .xlsm)Reliable macro and VBA support for robust automation tasksFree and lightweight spreadsheet solution without heavy overheadFamiliar user interface for a seamless transition from Microsoft Office
microsoft office alternative - wps office

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.