Questions And Answers

More Tutorials

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:


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:


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 #"
Private Const MODULE_CONSTANT As String = "Something relevant to this Module"
Public Sub SomeProcedure()
End Sub


In this page (written and validated by ) you learned about VBA Naming Conventions . What's Next? If you are interested in completing VBA tutorial, your next topic will be learning about: VBA Procedure Names.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.