Best Practices VBA code based Excel Projects
These are our TEN COMMANDMENTS for VBA Coding in Excel. These help us write efficient Excel VBA Macros.
1. Comment. Comment. Comment: Detailed, non-technical documentation helps satisfy the curiosity of Customer. It assists when memory fails.
2. We round off calculations only at the final output stage. This increases accuracy and minimizes “rounding-off” differences.
3. We minimize, if not eliminate,Hard Coding. We declare our Variables parameters at the start of our procedures. This makes our code more flexible and easier to maintain.
4. Utilize Built-In Functions: No need to reinvent wheel.
5. Disable Screen Updating and set Calculations to Manual while VBA code runs
6. Plan The Code Structure before we start coding so that we create clean and efficient code.
7. Minimize Unnecessary Loops since they slow down our code.
8. Optimize Memory Usage by releasing/closing resources at the end of sub procedure.
9. Select and Activate Statements slow down our code. We minimize using them.
10. We use Arrays to Edit Large Ranges. This significantly speeds up our code.