Finance

Charts

Statistics

Macros

Search

Operator Precedence In Excel VBA

When an expression contains multiple operations, the individual subexpressions are evaluated and resolved in a specific order called the operator precedence or priority.

Precedence Operator(s) Description
1 ^ Exponentiation (power operator)
2 Unary – Negative sign (negation)
3 * and / Multiplication and division
4 \ Integer division
5 Mod Modulo operation
6 + and – Addition and subtraction
7 & String concatenation
8 =, <>, <, >, <=, >=, Like Comparison operators (Note: = means comparison, not assignment)
9 Not Logical NOT
10 And Logical AND
11 Or Logical OR
12 Xor Logical exclusive OR

Operators of the same precedence level are evaluated left to right.

As mentioned earlier with arithmetic operators, this precedence can be overridden using parentheses, forcing specific expressions to be evaluated before others. Expressions inside parentheses always have priority, but inside them, normal precedence rules apply again.

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx