This article describes the operators available in VBA, their order of precedence in calculation and the types of data returned by each operator in an expression.

Operator evaluation proceeds from left to right in an expression, except that evaluation of operators with a higher precedence to the right of the current operator occurs before those lower precedence operators to their left.

If you are ever uncertain of how Excel approaches a calculation, you can use the Immediate Window in the VBA Editor to test expressions. Note that unless type characters are appended to numbers or values are expressly decimal, the Immediate Window will assume integer values.

The table below sets out all the operators in VBA with their relative precedence in calculation. It shows the relative level of precedence of each set of operators. Operators listed with the same precedence are evaluated in the order in which they appear in an expression, as their precedence is equivalent.

Precedence | Operator | Result Type | Description |

1 | ( ) | Varies | Grouping operatorsPlacing parentheses around any part of an expression ensures that the parts of the expression inside the parentheses are evaluated prior to operators either side. The order of precedence within the parentheses is resolved on the basis of the precedence listed here. The result type of an expression in parentheses is the result type of the lowest order operator within the parentheses. |

2 | - | Numeric† | Unary negation operatorTakes one value only on its right. Returns the result of sign-switching the value on the right of the operator. |

3 | ^ | Numeric† | Exponentiation operatorReturns the result of raising the value on the left of the operator to the power of the value on the right of the operator. |

4 | * | Numeric† | Multiplication operatorReturns the product that is the result of multiplying the value on the left of the operator by the value on the right of the operator. |

4 | / | Numeric† | Division operatorReturns the dividend that is the result of dividing the value on the left of the operator by the value on the right of the operator. |

5 | \ | Integer Long LongLong | Integer Division operatorReturns the integer dividend that is the result of dividing the integer value of the value on the left of the operator by the integer value of the value on the right of the operator. |

6 | Mod | Integer Long LongLong | Integer Modulo operatorReturns the integer dividend that is the result of dividing the integer value of the value on the left of the operator by the integer value of the value on the right of the operator. |

7 | + | Numeric† | Addition operatorReturns the sum that is the result of adding the value on the right of the operator to the value on the left of the operator. |

7 | - | Numeric† | Subtraction operatorReturns the difference that is the result of subtracting the value on the right of the operator from the value on the left of the operator. |

8 | & | String | String Concatenation operatorReturns the string result formed by appending the characters from the value to the right of the operator to the end of the string of characters from the value to the left of the operator. |

9 | = | Boolean | Equality operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

9 | <> | Boolean | Inequality operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

9 | < | Boolean | Less Than operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

9 | <= | Boolean | Less Than or Equal to operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

9 | > | Boolean | Greater Than operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

9 | >= | Boolean | Greater Than or Equal to operatorReturns the result of comparing the value on the left of the operator to the value on the right of the operator. |

10 | Like | Boolean | Like operatorReturns the result of comparing the value on the left of the operator to string pattern given in the value on the right of the operator. Returns True if the patterns match, otherwise returns False. |

11 | Is | Boolean | Is operatorReturns the result of comparing the object reference on the left of the operator to the object reference on the right of the operator. Returns True if both references are to the same object, otherwise returns False. |

12 | Not | Boolean | Logical Not operatorReturns the logical not of he value on its right. Returns True if the value on the right is false, otherwise returns True. |

13 | And | Boolean Numeric† | Logical And operatorReturns the logical And derived by bitwise comparison of the value on the left and the value on the right. In the result, the bits on will be those that corresponde to the ones that are on in both values. |

14 | Or | Boolean Numeric† | Logical Or operatorReturns the logical Or derived by bitwise comparison of the value on the left and the value on the right. In the result the bits on will be those that corresponde to the ones that are on in either of the values. |

15 | Xor | Boolean Numeric† | Logical Exclusive Or operatorReturns the logical Exclusive Or derived by bitwise comparison of the value on the left and the value on the right. In the result the bits on will be those that correspond to those that are on in only one of the vaues. |

16 | Eqv | Boolean Numeric† | Logical Equivalence operatorReturns the logical Equivalence derived by bitwise comparison of the value on the left and the value on the right. In the result the bits on will be those that correspond to that are either both on or both off in both values. |

17 | Imp | Boolean Numeric† | Logical Implication Or operatorReturns the logical Exclusive Or derived by bitwise comparison of the value on the left and the value on the right. In the result all bits will be on except those that correspond to the onse where the bit is on in the value on the left and off in the value on the right. |

The table above can be sorted by operator, precedence and filtered by data type returned.

† Numeric return values may include Interger, Long, LongLong, Single, Double, Decimal, Currency or Date, depending upon the types of values passed to an expression, and the way in which unmateched data types are cast.