Types of operators in Excel VBA
In our scripts we will use both arithmetic expressions and use logical expressions. For this purpose, we will be able to use operators in Excel VBA, we can divide them into 3 groups:
 arithmetic
 logic
 comparison.
VBA operators: arithmetic
Arithmetic operators serve as the name suggests the implementation of actions math. When creating a procedure containing mathematical operations, it may also be necessary to use parentheses. We write them in the standard way: “()”.
Operator  Name  Example  
+  Addition 


–  Subtraction 


*  Multiplication 


/  Division 


\  Sharing without rest 


^  exponentiation 


mod  Modulo (the rest from sharing) 


+ and &  Adding strings 

As you can see, the “+” operator can also be used to connect strings to each other. For the same purpose, we can also use the operator: “&”, an example of which is described below.
1 2 3 4 
Sub SumOperators() MsgBox "wyraz_1 " & "wyraz_2" MsgBox "wyraz_1 " + "wyraz_2" End Sub 
If we want to use the minority and majority operators in relation to letters, the procedure will return true or false depending on which place the given letter occupies the alphabet.
1 2 3 4 
Sub LogOperators() MsgBox "A" < "B" 'zwróci wartość True MsgBox "A" = "B" 'zwróci wartość False End Sub 
VBA operators: comparison
Comparison operators are used to compare selected data. Their description and application example are below. Using the following construction, the result will be True or False each time.
Operator  Name  Example  
=  equal 


<>  uneven 


> =  Bigger than 


<=  Smaller than 


>  Bigger 


<  Smaller 

VBA operators: logical
The basis for a good script is correctly logic. We will use logical operators to save it.
Operator  Name  Example  
and  Conjunction 
‘will return True 

Or  Alternative 
‘will return True 

xor  An alternative with one choice. Returns false only if more than one condition is true 
‘will return False 

not  Negation 
‘will return true 
Tasks (You can save the result in a comment)
 Record any action using all the arithmetic operators at the same time. The result of the activity should be the number 100.
More examples of Excel VBA basics can be found in the Excel VBA Course section and Excel VBA How To section. If you have any questions about this chapter, you can post them on the forum without logging in.