I am trying this code
Code: Select all
Sub Test()
Dim jumpLabel As String, n As Long
n = 5
jumpLabel = IIf(n = 5, "Line1", "Line2")
GoTo jumpLabel
Line1:
Debug.Print "Line1"
Exit Sub
Line2:
Debug.Print "Line2"
Exit Sub
End Sub
I need to know if it is a possible logic
I can solve the problem using this version
Code: Select all
Sub Test()
Dim n As Long
n = 5
If n = 5 Then GoTo Line1 Else GoTo Line2
Line1:
Debug.Print "Line1"
Exit Sub
Line2:
Debug.Print "Line2"
Exit Sub
End Sub