VBA has no Exit If. To skip the rest of an If block, put the code that should run in the other case in the Else branch, or reverse the test so the block runs only when it should:
<pre>If Range("A1").Value = "" Then</pre>
Range("A1").Value = InputBox("Enter a value")
Else
MsgBox "A1 already has a value."
End If
To leave more than the If, use the exit statement for the structure around it. Exit For and Exit Do leave a loop and carry on from the line after it; Exit Sub and Exit Function end the procedure and return to whatever called it.
A guard clause at the top of a procedure keeps the rest of the code out of an If altogether: If Range("A1").Value = "" Then Exit Sub stops the macro straight away when there’s nothing to work on.
If you jump out of an If with GoTo, code that reaches the label in the normal way runs it too. Without Exit Sub before the label, the code you meant to skip runs whenever the If didn’t jump.
In VBA, when you use the IF statement, you can use a GoTo statement to Exit the IF. Let me clarify here; there’s no separate exit statement that you can use with IF to exit. So, it would be best if you used goto to jump out of the IF before the line of the end statement reached.
Let’s look at an example to understand this.

In the above example, as you can see, we have used an IF statement to check if there’s a value in cell A1 or not. When you run this code, and there’s no value in the A1, VBA will jump to the “Lable1” and run the code under it. So, it will show an input box to enter the value in cell A1.
Sub myMacro()
If Range("A1") = "" Then
GoTo Lable1
Else
MsgBox "there's a value in the cell."
End If
Lable1:
Range("A1").Value = _
InputBox("Enter Value")
End Sub
There will be a few situations when you need to exit an IF statement while writing a VBA code. As you know in the single IF statement, there can only be two conditions, and if one condition is true, VBA will run the code that you have mentioned for it and then exit the statement automatically.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.