USING ASSIGNMENT STATEMENTS

An assignment statement is a statement containing the assignment operator "=" that assigns a literal value, the value of a variable or the value of an expression to a variable or object.

The syntax of an assignment statement is

VariableName = Expression

where VariableName is the name of a variable that has been declared, and Expression is either a literal, a variable, or an expression which can be evaluated to a value.

The same syntax applies in the case of an object rather than a variable.

Examples of assignment statements (assuming that the variables have been declared):

NumberMoles = 0.327                 'setting the number of moles to 0.327
x = x + 1                           'incrementing the value of x by one
x = (y + 2) / (z - 3)               'assign x a value based on the values of y and z
FileOpen = True                     'setting a boolean variable to True
Range("BirthYear").Value = 1988     'assigning a property value of an object
VBA uses the equal sign as the assignment operator. The above statement, x = x + 1, means that to take the value that is stored in variable x, add 1 to it, and assigned the resulting value to x. As a result the value originally stored in x is incremented by 1.

If you interpret the "=" as the equal sign as in mathematics, you will have a great conceptual difficulty, since there is nothing whose value is equal to 1 greater than itself (i.e., the "equation" would have no solution!).