Code Cleaning

As you are writing a VBA program, name spaces and other structures are created invisibly in the background to track and manage your project. As you rewrite and move code and objects, unused structures build up in your project. These development leftovers do not affect the average user, since they don't add up to enough to make a significant difference. But large and/or complex development efforts can benefit from periodic removal of these unused structures. Removing these development leftovers is often called "cleaning your project" or "stripping your code."

Cleaning a project involves saving all of its modules and forms out to text files, deleting the old modules and forms, and then reimporting the modules and forms from the text files. Larger projects may see a 25-percent reduction in file size once you've cleaned them. This reduction in file size may or may not make any real difference in the load time or the run time of your project.

Be sure to recompile your project after this cleaning. The load time saved by the reduced file size can be negated if the modules must re-compile on startup. When you create your add-in using the Microsoft Excel File/Save As menu or setting the IsAddin property of the Workbook object, your add-in is NOT automatically compiled. You compile your project manually from within the VBE by choosing Debug/Compile VBAProject from the VBE menu.

Committee add-ins should minimize their impact on memory and resources. Always clean your code before final testing and shipping. Generally speaking, dictator add-ins may be more forgiving in this area since you are in control of the size of the overall project.