VBA Arithmetic Operators in Excel (original) (raw)

Last Updated : 16 Oct, 2022

Arithmetic Operators are the operators which perform mathematical operation or which perform any operation between two numbers like addition(+), subtraction(-), multiplication(*), division( / ), exponentiation(^), modulus(Mod), Bit-Shift operations. In this article, we will learn about the excel VBA arithmetic operators in detail.

Addition Operator (+)

The Addition operator is used to add numbers. We use the (+)plus operator as a symbol for addition. For example, if we want to add 12 and 14 to get 26,then we will use the (+)plus operator. Declare a variable x, and now, write x = 12 + 14, hence, x stores 26 in it.

Addition

Subtraction Operator (-)

The Subtraction operator is used to find the difference between two numbers. We use the (-)minus operator as a symbol for subtraction. For example, if we want to subtract 14 and 12 to get 2, then we will use the (-)minus operator. Declare a variable x, and now, write x = 14 - 12, hence, x stores 2 in it.

Subtraction

Multiplication Operator (*)

The Multiplication operator is used to multiply numbers. We use the (*)asterisk operator as a symbol for multiplication. For example, if we want to multiply 4 and 2 to get 8, then we will use the (*)asterisk operator. Declare a variable x, and now, write x = 4 * 2, hence, x stores 8 in it.

Multiplication

Division Operator (/)

The Division operator is used to divide numbers. We use the (/)forward slash operator as a symbol for division. For example, if we want to divide 40 and 20 to get 2, then we will use the (/)forward slash operator. Declare a variable x, and now, write x = 40 / 20, hence, x stores 2 in it.

Division

Exponentiation Operator (^)

The Exponentiation operator is used to get the power of a number. We use the (^)caret operator as a symbol for exponentiation. For example, if we want to exponent 20 with 2 to get 400, then we will use the (^)caret operator. Declare a variable x, and now, write x = 20 ^ 2, hence, x stores 400 in it.

Exponentiation

Modulus Operator (Mod)

The Mod operator is used to find the remainder of two numbers. We can write Mod itself, for finding the mod of two numbers. For example, if we find mod of 94 and 6 we get 4. Declare a variable x, and now, write x = 94 Mod 6, hence, x stores 2 in it.

Modulus

Bit-Shift Operations

The Bit-Shift operators are (<<) left-shift** operator and **(>>) right-shift operator. The left-shift operator, shifts bits to the left, a number of times, as mentioned. For example, num << 4**, shifts the bits of number **num**, **4** times. Similarly, the right-shift operator, shifts bits to the right, a number of times, as mentioned. For example, **num >> 2, shifts the bits of number num, 2 times.

Bit Left Shift Operations

Right Shift