It is important for a any developer to follow best practice in terms of code layout for various reasons, such as:
Collaborative Projects – You want you and your colleagues to understand each others work quickly, without having to read through the whole code, reading into each line.
Sharing Work – Whether you decide to post your work on your blog, share a useful macro with a friend or if you have done some work for a client, people would expect you to write code in a similar matter to everyone else.
Think About Yourself – At the end of the day, if you’re working on a big project, you want to be able to write the whole application in one style or layout, so it is easier for you to copy/paste certain lines of code, and to check your program against errors.
For most of the languages, you can find various client applications, which will automatically organise and colour code your code for ease of use. Unfortunately, for VBA we only use Microsoft Native software, which does not perform such duties.
This is why I have decided to come up with best practice rules for VBA coding, in order to make this language more accessible to newcomers, as well as to encourage collaboration between frequent users, sharing their secrets with developer peers.
In the next few posts, we will look at best ways to layout your code, provide commentary, naming conventions, and much more.
We will start with VBA Etiquette & Best Practice – Chapter 1 – “Module Layout”