Data whose values do not change within a certain scope should be declared as constants by using the const modifier.
The value of a constant is specified when it is declared (this process is called initialiation).
Any attempts to alter the value of a constant then results in a compilation error.
Using constants instead of hard-code literal values is an excellent programming practice.
This makes your code more readable and easier to be modified later on if needed.
Examples of using constants:
Const QuarterPerDollar As Integer = 4 Public Const Pi As Single = 3.14159625 'a public constant available to all modules in a workbook Const MyName As String = "Albert Einstein" Const Rate = 0.0525, Duration = 12 '2 constant variantsLike variables, constants have a scope:
Sun CalcManual( ) Application.Calculation = xlCalculationManual End SubThe actual value of the predefined constant xlCalculationManual is -4135, but you do not need to this value to use the constant.