How to Declare Constant Variable in VBA ?

Ans : We Can Declare Constant Variable in Below Three Ways :


A) Procedure Level :

Within Procedure : Scope Limited to Procedure Only

For Ex :

Const Color As String="Blue"

Debug.print Color

B) Module Level :

Within Module : Scope Within Module,Scope for any Procedure and Function within Module

For Ex :

Const Hrs As Long = 2

C) Project Level :

Within Any Module but declared with Public Keyword

For Ex :

Public Const Color As String="Blue"

Post a Comment

Previous Post Next Post