QP School
If...Then...Else in VBA - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: Excel VBA Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=48)
+--- Thread: If...Then...Else in VBA (/showthread.php?tid=5213)



If...Then...Else in VBA - Qomplainerz - 07-26-2023

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