Excel VBA best practices – coding standards – variables

8 May 2013

The easiest and highest impact way to implement coding standards is to adopt a disciplined way of naming VBA variables. What follows is SpreadSheet SuperStar's variable naming rules:

  • Use Dim statement to declare all VBA variables.
  • Use Option Explicit in all VBA modules.
  • Assign every VBA variable a data type.
  • Name VBA variables with descriptive names.
  • Use data type prefixes for each VBA variable.
  • One variable declaration per line of code.
  • Declare all variables at the top of each subroutine.
  • Style points: Order variables declarations by size.