Course Content
Chapter 9 – Multiple Worksheets and Workbooks
0/2
Chapter 10 – IF, VLOOKUP, and Other Functions
0/3
Excel Course: Beginner to Pro
About Lesson

EXCEL VBA OPERATORS

 

A simple statement like “4 + 5” defines an Operator. In this case, the numbers 4 and 5 are called operands, while the addition symbol + is called the operator. The following types of operators can be used in VBA:

  1. Arithmetic Operators:
  2. Comparison Operators:
  3. Logical Operators:
  4. Concatenation Operator:
  5. Assignment Operator:

 

1.Arithmetic Operators:

 

Addition (+): Used to add two values together. For example: result = 5 + 3

Subtraction (-): Used to subtract one value from another. For example: result = 10 – 5

Multiplication (*): Used to multiply two values. For example: result = 2 * 3

Division (/): Used to divide one value by another. For example: result = 10 / 2

Modulus (): Returns the remainder of a division operation. For example: result = 10 3 (result will be 1)

 

2.Comparison Operators:

Equal to (=): Compares two values for equality. For example: result = (5 = 5) (result will be True)

Not equal to (<>): Compares two values for inequality. For example: result = (5 <> 3) (result will be True)

Greater than (>): Checks if one value is greater than another. For example: result = (10 > 5) (result will be True)

Less than (<): Checks if one value is less than another. For example: result = (3 < 5) (result will be True)

Greater than or equal to (>=): Checks if one value is greater than or equal to another. For example: result = (5 >= 5) (result will be True)

Less than or equal to (<=): Checks if one value is less than or equal to another. For example: result = (3 <= 5) (result will be True)

 

 

 

 

3.Logical Operators:

AND: Performs a logical AND operation. For example: result = (True And False) (result will be False)

OR: Performs a logical OR operation. For example: result = (True Or False) (result will be True)

NOT: Performs a logical negation. For example: result = Not True (result will be False)

 

4.Concatenation Operator:

Ampersand (&): Used to concatenate (join) strings together. For example: result = “Hello” & ” World” (result will be “Hello World”)

 

5.Assignment Operator:

Equal to (=): Used to assign a value to a variable or a cell. For example: variable = 10 or Range(“A1”).Value = 10