Office for Mac Issues

Fix Missing Spaces in the Excel VBA Editor on Mac

Huda QurayshiHuda Qurayshi Nov 18, 2026 869 views

Question details

The user needs to preserve necessary spacing and continue VBA statements correctly in the Excel VBA editor on Mac.

Fix Missing Spaces in the Excel VBA Editor on Mac
Product
Microsoft Excel for Mac VBA editor
Device & OS
macOS
Scenario
Editing VBA code in Excel for Mac, including statements that span multiple lines.
Observed behavior
Spaces typed at the end of a line disappear, and VBA instructions appear joined together.
Before you start

Open the affected workbook in Excel and check whether the missing spaces are at the end of a line or between VBA tokens. Trailing spaces alone do not continue a statement onto the next line.

Solution 1Recommended

Use Explicit VBA Line Continuation

Use a space followed by an underscore when one VBA statement needs to continue on the next line.

1
Open the VBA code

In Excel for Mac, open the Visual Basic Editor from Tools > Macro > Visual Basic Editor, then open the affected module.

2
Add a continuation character

At the end of the first line of a statement, type a space followed by an underscore. For example, enter `result = value1 + _` and put `value2` on the next line.

3
Check the statement

Keep required spaces between tokens within each line, then use Debug > Compile VBAProject to check for syntax errors.

Use Explicit VBA Line Continuation
Trailing spaces are not line continuation: Spaces at the end of a line may be removed by the editor. The space before the underscore is part of VBA's explicit continuation syntax.
Free Microsoft Office alternative

Work With Excel Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with compatible Excel spreadsheets, making it easy to move everyday spreadsheet tasks from Microsoft Office. It does not fix the Excel VBA editor, and VBA macro compatibility may vary.

Open and edit compatible Microsoft Excel XLSX and XLS filesUse familiar spreadsheet tools for everyday workbook editingWork in a lightweight office suite with a free versionContinue non-macro spreadsheet tasks while troubleshooting Excel VBA
microsoft office alternative - wps office

Frequently Asked Questions

Why do spaces at the end of a VBA line disappear?

The VBA editor may trim trailing whitespace. Those spaces do not continue a statement; use a space followed by an underscore at the end of the line when explicit continuation is needed.

How do I continue a VBA statement on another line?

In the VBA editor, end the first line with a space and an underscore, then enter the rest of the statement on the next line. For example, use `result = value1 + _` followed by `value2` on the next line.

What should I do if spaces between VBA words disappear?

In the Visual Basic Editor, choose Insert > Module and test a short statement. If the issue continues, review the editor settings and choose Help > Check for Updates in Excel.

Can WPS Office fix the Excel VBA editor?

No. WPS Office is a separate spreadsheet alternative and cannot repair Excel's VBA editor. It can open compatible Excel files for everyday editing, but VBA macro compatibility may vary.