VBA's 10 Commandments

Ten Commandments of Excel VBA Programming

  1. Thall shalt know thy problem. Make sure we understand completely before proceeding

  2. Thall shalt not reinvent the wheel. Research/Google to see if someone else has already solved this.

  3. Thall shalt not reinvent the wheel part deux. Try to solve the problem without VBA first.

  4. Thall shalt not create monolithic idols. Break problems into smaller problems which will become tightly focused functions.

  5. Thall shalt assume things will go wrong. Add error checking (NOT IGNORING) to all routines.

  6. Thall shalt code for reusability. Avoid constants and literals in routines. Pass as parameters or consider externalizing in tables.

  7. Thall shalt code with structure. Grouping like things together and placing them in order makes coding easier and code more maintainable

  8. Thall shalt use OPTION EXPLICIT. Declare all variables.

  9. Thall shalt use appropriate variable types. Don’t use variants to avoid thinking.

  10. Thall shalt test. TRY to break our routines before putting them into production. It will save us a lot of embarrassment and our reputations.