logo
search
VBA & Macro Problems

How to Fix SUMIFS Formula Displaying as Text via VBA in Excel

Bushra ParveenBushra Parveen Oct 8, 2026 869 views

Question details

The user needs to correctly insert a SUMIFS formula referencing a network drive into a cell using VBA, ensuring it calculates properly rather than being formatted as text.

How to Fix a VBA SUMIFS Formula Displaying as Text in Excel
Product
Excel
Device & OS
not provided
Scenario
Using VBA to dynamically insert a SUMIFS formula into a specific cell that references another workbook on a network drive.
Observed behavior
The inserted formula begins with a leading apostrophe (e.g., '=SUMIFS) and is displayed as plain text in the cell instead of evaluating the result.
Before you start

Ensure your Excel workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have enabled macros in the Trust Center before modifying your VBA scripts.

Solution 1Recommended

Remove the Leading Apostrophe in the VBA String

Correct the VBA code by removing the apostrophe before the equals sign to ensure the application evaluates the formula instead of treating it as text.

When writing VBA code to insert formulas, placing a single apostrophe (') directly before the equals sign forces the cell to treat the entry as text. Removing this character will restore standard formula calculation.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Locate the Target Macro

In the Project Explorer panel on the left, double-click the module or worksheet containing your formula insertion script.

3
Modify the Formula String

Find the line of code assigning the formula. Change it from Range("X12").Formula = "'=SUMIFS(...)" to Range("X12").Formula = "=SUMIFS(...)". Ensure the apostrophe following the opening quotation mark is completely deleted.

4
Save and Run

Press Ctrl + S to save the code. Return to your worksheet and run the macro again; the cell should now display the calculated result of the SUMIFS formula.

Remove the Leading Apostrophe in the VBA String
Check Cell Formatting: If the formula still does not calculate after removing the apostrophe, ensure the target cell's number format is set to 'General' rather than 'Text' before running the macro.
WPS Macro Support

Write and Execute VBA Macros in WPS Spreadsheet

WPS Office provides robust support for macros and complex formulas like SUMIFS. You can seamlessly run your existing VBA scripts to automate tasks and manage network drive references without text-formatting errors.

  1. 1. Open Your Workbook in WPS: Launch WPS Office and open your Macro-Enabled Workbook (.xlsm).
  2. 2. Access the Developer Tab: Navigate to the 'Developer' tab on the main ribbon to access your macro and coding settings.
  3. 3. Edit the Macro Code: Click on 'Visual Basic' to open the code editor and modify your SUMIFS script, ensuring formulas are formatted without a leading apostrophe.
  4. 4. Execute the Script: Click the 'Run Macro' button to dynamically insert and calculate the SUMIFS formula seamlessly across your network references.
Advanced VBA and Macro support for automating repetitive Excel tasksFull compatibility with Microsoft Excel formulas including SUMIFS and XLOOKUPNatively handles .xlsm and .xlsx file formats without data lossLightweight application with a highly responsive code execution engine
QA img-9

Frequently Asked Questions

Why do formulas entered via VBA sometimes show as text?

This typically happens if the target cell's format was pre-set to 'Text' before the macro executed, or if the VBA code intentionally or accidentally included a leading apostrophe before the formula's equals sign.

How do I insert VBA variables into a SUMIFS formula?

You can insert variables into your formula string using the ampersand (&) operator to concatenate the text. For example: Range("A1").Formula = "=SUMIFS(B:B, C:C, " & myVariable & ")".

Does WPS Office support Excel VBA scripts for formulas?

Yes, WPS Office fully supports VBA macros. You can open your Excel .xlsm files in WPS Spreadsheet and execute most standard VBA scripts, including those that manipulate ranges and insert complex formulas.