Fix Missing Spaces in the Excel VBA Editor on Mac
Question details
The user needs to preserve necessary spacing and continue VBA statements correctly 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.
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.
Use Explicit VBA Line Continuation
Use a space followed by an underscore when one VBA statement needs to continue on the next line.
In Excel for Mac, open the Visual Basic Editor from Tools > Macro > Visual Basic Editor, then open the affected module.
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.
Keep required spaces between tokens within each line, then use Debug > Compile VBAProject to check for syntax errors.

Test and Troubleshoot Spaces Between VBA Tokens
Use these checks if spaces disappear between words or operators while you type, rather than only at the ends of lines.
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.

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.




