It is important to write your code in a clear and organized fashion so other programmers can understand what you did and why you did it. Here are some rules you should follow whenever you develop an application in VBA:
- Use names for procedures and variables that make sense with respect to the problem.
- When declaring a procedure, always include its purpose as a comment.
- Definition names of variables and functions should use camel case Eg. LogBaseN rather than Log_Base_N or logbasen
- Don’t perform multiple tasks in a single line. As a result, no code line should span more than your screen width.
- Break long procedures into shorter, simpler procedures. No procedure should span more than ten to twenty lines.
- Avoid hard coding or embedding input or configuration data directly into the source code. For example, instead of saying x=10*y, define a new variable a=10 and say x=a*y.