Operators

An operator is a symbol that instructs VBA to manipulate data in some manner. Adding two numbers together is an example. VBA operators fall into several categories.

The Assignment Operator

Perhaps the most fundamental operator is the assignment operator, represented by the equal sign. When the assignment operator is used in a statement, the value of the expression on the right side of the operator is assigned to the variable on the left side of the operator. For example, the statement

x = y + z

adds the values in variables y and z and assigns the result to x.

When using the assignment operator with object references, you must use the Set keyword. Assuming that obj1 and obj2 have been declared as object types, and obj1 is a reference ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.