QP School

Full Version: If...Then...Else in VBA
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Description:

The If statement checks a condition and executes a block of code if the condition is true.
If the condition is false, it can execute an alternative block (Else).

Example:

Sub ExampleIfThenElse()
    Dim age As Integer
    age = 25

    If age >= 18 Then
        MsgBox "You are an adult."
    Else
        MsgBox "You are a minor."
    End If
End Sub