Monday, September 26, 2022

Basic Operator for Excel VBA

Before start your 1st code it is better to understand basic operator purpose and function as below table. Certain operator can be use as different function for example + and =.

No. Category Operator Purpose Example Result
1 Numeric Variables + Sum 2 + 5 7
2 Numeric Variables - Minus 5 - 2 3
3 Numeric Variables * Multiply 5 * 5 25
4 Numeric Variables / Divide 5.5 / 2 2.75
5 Numeric Variables ^ Exponential 5.5 ^ 2 30.25
6 Numeric Variables = Equivalent 2 + 5 = 7
7 String/Variables = Assign MyVar = "C:\MyFiles"
8 Property/Object = Assign Set MyVar = ActiveSheet
9 String/Variables + Concatenation "Hello " + "World" Hello World
10 String/Variables & Concatenation "Hello " & "World" Hello World
11 Numeric Integer \ Divide 5.5 / 2 2

The above table just a basic operator not comparison operator.

Microsoft Reference-Operator-summary
Microsoft Reference-Operator (* Operator)
Microsoft Reference-Caret-operator (^ operator)
Microsoft Reference-Plus-operator (+ operator)
Microsoft Reference-Ampersand-operator (& operator)
Microsoft Reference-Equals-operator (= operator)
Microsoft Reference-Minus-operator (- operator)
Microsoft Reference-Forwardslash-operator (/ operator)
Microsoft Reference-Backslash-operator (\ operator)

Practice makes perfect. Thank You.

No comments:

Post a Comment