VBA Naming Conventions
Variable Names
Variables hold data. Name them after what they're used for, not after their data type or scope, using a noun. If
you feel compelled to number your variables (e.g. thing1, thing2, thing3), then consider using an appropriate
data structure instead (e.g. an array, a Collection, or a Dictionary).
Names of variables that represent an iteratable set of values - e.g. an array, a Collection, a Dictionary, or a Range
of cells, should be plural.
Some common VBA naming conventions go thus:
For procedure-level Variables:
camelCase
Public Sub ExampleNaming(ByVal inputValue As Long, ByRef inputVariable As Long)
Dim procedureVariable As Long
Dim someOtherVariable As String
End Sub
For module-level Variables:
PascalCase
Public GlobalVariable As Long
Private ModuleVariable As String
For Constants:
SHOUTY_SNAKE_CASE is commonly used to differentiate constants from variables:
Public Const GLOBAL_CONSTANT As String = "Project Version #1.000.000.001"
Private Const MODULE_CONSTANT As String = "Something relevant to this Module"
Public Sub SomeProcedure()
Const PROCEDURE_CONSTANT As Long = 10
End Sub