vba if
vba if
vba
Copy
Sub IfExample()
Dim number As Integer
number = 15
vba
Copy
Sub IfElseExample()
Dim number As Integer
number = 5
vba
Copy
Sub IfElseIfExample()
Dim number As Integer
number = 10
vba
Copy
Sub NestedIfExample()
Dim number As Integer
number = 8
And:
vba
Copy
Sub IfAndExample()
Dim number As Integer
number = 7
Or:
vba
Copy
Sub IfOrExample()
Dim number As Integer
number = 3
Not:
vba
Copy
Sub IfNotExample()
Dim isActive As Boolean
isActive = False
Key Points:
If checks if a condition is True, and if it is, it runs the code block inside.
You can use Else to specify code to run if the condition is False.
Logical operators (And, Or, Not) can help you combine multiple conditions into one
If statement.
=: Equal to
vba
Copy
Sub ComparisonOperatorsExample()
Dim age As Integer
age = 20