Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there any way to automatically remove all comments, excess spaces, and blank lines from a VBA module?

0
Posted

Is there any way to automatically remove all comments, excess spaces, and blank lines from a VBA module?

0

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.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.