VBA & Macro Problems

Fix an Excel Custom Function Returning Incorrect Totals in Microsoft 365

Tauseeq MagsiTauseeq Magsi Nov 13, 2026 868 views

Question details

Restore the correct result from an Excel VBA custom function that sums a range while excluding cells formatted with strikethrough.

Fix an Excel Custom Function Returning Incorrect Totals in Microsoft 365
Product
Microsoft Excel for Microsoft 365
Device & OS
Windows and macOS
Scenario
A shared XLSM workbook contains a custom function that previously worked on staff members' Windows computers and the author's Mac.
Observed behavior
The custom function still exists, but it no longer returns the correct total. The initial report that macros had disappeared was later corrected.
Before you start

Identify one formula cell with an incorrect result and calculate its expected total manually, excluding the struck-through values. Confirm whether the strikethrough was applied directly through Format Cells or through conditional formatting.

Solution 1

Confirm the workbook format and locate the custom function

Use this check to distinguish missing VBA code from an existing function that produces an incorrect result.

1
Check the file extension

Check the workbook's filename or open File > Save As to inspect its file type. A macro-enabled workbook should use .xlsm, and a macro-enabled template should use .xltm. Saving as .xlsx does not preserve VBA code.

2
Open the VBA editor

Open Developer > Visual Basic and expand the workbook's project and Modules folder. Locate the Function procedure used by the worksheet formula. Developer > Macros lists runnable macros, but worksheet custom functions generally do not appear there.

3
Match the formula to its code

Select the cell with the incorrect total and inspect its formula in the formula bar. Confirm that the function name matches the VBA Function procedure and that its range argument includes the intended cells.

Changing the extension does not restore deleted code: If the workbook was saved as .xlsx and its VBA project was removed, saving it as .xlsm afterward will not recover the code. Retrieve the original macro-enabled workbook or a version that still contains the function.
Free Microsoft Office alternative

Use WPS Spreadsheet for a Formula-Based Exclusion Total

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for easy migration of standard files. For this task, use an explicit inclusion column and SUMIF instead of depending on strikethrough formatting. WPS does not repair an Excel VBA function; verify macro support before moving a VBA-dependent workbook.

Calculate exclusion totals with a status column and SUMIF rather than font formatting.Supports Microsoft Excel .xlsx files for standard spreadsheet content.Provides a familiar interface for editing formulas, ranges, and cell formatting.Offers a free, lightweight option for everyday spreadsheet work.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my custom function missing from Developer > Macros?

The Macros dialog generally lists runnable Sub procedures, not worksheet Function procedures. Open Developer > Visual Basic and look in the workbook's Modules folder for the function used in your formula.

Why does applying strikethrough not update my total?

Formatting changes do not normally trigger recalculation. Select the custom-function formula, click it in the formula bar, and press Enter to reevaluate it. If that fixes the result, consider using a separate inclusion column so changes become calculation inputs.

Can Font.Strikethrough detect strikethrough from conditional formatting?

Font.Strikethrough checks the cell's direct font formatting, not necessarily the appearance produced by conditional formatting. Open Home > Conditional Formatting > Manage Rules to inspect the rule, then base the calculation on that rule's condition.

How can I sum included rows without VBA?

Enter amounts in A2:A100 and mark included rows with Include in B2:B100. In the total cell, enter =SUMIF(B2:B100,"Include",A2:A100). You can still apply strikethrough for visual reference, but the status column determines the total.

Does saving the workbook as XLSM fix an incorrect function result?

No. The .xlsm format preserves existing VBA code, but it does not correct the function's logic or recalculation behavior. If the code is present in Developer > Visual Basic, test its range, strikethrough check, and calculation behavior.