Module Level (Private)
A module level variable is declared in the declarations section of a code module (standard, class or userform).
Module level variables can have two flavours either Private or Dim.
If you declare a variable at the top of a module with the Public statement it is not module level, its global level.
Private m_sModuleLevel As String
Dim m_sModuleLevel As String
You must insert these statements at the very top of your modules, before any procedures or functions.
A private variable at the top of a module can only be used in the module it is declared in.
A private variable at the top of a module cannot be used outside that module.
Private or Dim ?
If you declare a module level variable with the Dim statement this is equivalent to using the Private statement.
Using Dim for module level variable can cause confusion and should be avoided.
Private m_sModuleLevel As String
Dim m_sModuleLevel As String
Public Sub Procedure_Name()
End Sub
Always use Private for Module Level variables.
Const
If you declare a module level variable with the Const keyword this is equivalent to using Private Const.
Using just Const for module level constants can cause confusion and should be avoided.
Const m_lSTARTROW As Long = 5
Private Const m_lSTARTROW As Long = 5
Always use Private Const for Module Level constants.
link - learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/private-statement
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext