User Name Bob Johnson Date Started Jum Your Num

enforces a few rules regarding variable names:

You can use letters, numbers, and some punctuation characters, but the first character must be a letter.

You cannot use any spaces or periods in a variable name.

VBA does not distinguish between uppercase and lowercase letters.

You cannot use the following characters in a variable name: #, $, %, &, or! .

Variable names can be no longer than 254 characters. Of course, you're only asking for trouble if you use variable names 254 characters long.

To make variable names more readable, programmers often use mixed case (for example, InterestRate) or the underscore character (interest_rate).

VBA has many reserved words that you can't use for variable names or procedure names:

1 Built-in VBA function names such as Ucase and Sqr 1 VBA language words such as Sub, With, and For

If you attempt to use one of these names as a variable, you may get a compile error (your code won't run). So, if an assignment statement produces an error message, double-check and make sure that the variable name isn't a reserved word.

0 0

Post a comment