Is there any way to automatically remove all comments, excess spaces, and blank lines from a VBA module?
No. However, you can use the Edit Replace command from a VBA module to help you. For example, to remove excess spaces, replace all occurrences of two spaces with one space. And if you’ve used apostrophes only for comments, you can replace ‘* (that’s an apostrophe followed by an asterisk) with nothing – but make sure you check the Use Pattern Matching option. I know of no way to automatically remove blank lines from a VBA module. However, you can save the module as a text file, read the text file into a worksheet, manipulate it, and then copy it back to the module.
Is there any way to automatically remove all comments, excess spaces, and blank lines from a VBA module?