RAJAQ
11/29/2016 - 5:08 PM

## If Then End If I think this is best for if then commands if will terminate action if one condition is true - so macro doesn't waste time exe

If Then End If I think this is best for if then commands if will terminate action if one condition is true - so macro doesn't waste time executing remaining conditions.

``````Option Explicit
Dim Msg As String

Sub Greeting()

If Time < 0.5 Then
Msg = "Morning"
End If

If Time >= 0.5 And Time < 0.75 Then
Msg = "Afternoon"
End If

If Time >= 0.75 Then
Msg = "Evening"
End If

MsgBox "Good " & Msg

End Sub

' If there is no End If macro will continue to check all commands, which can increase the macro run time. Using End If is more efficient code as it will not run the code as soon as a condition becomes true.
``````