I want to display a message box with Yes, No, Cancel buttons and execute different code depending on which button is clicked.
What happens is this...user clicks Yes and code A executes. User clicks No and message redisplays, user clicks No again and code B executes. User clicks Cancel, message redisplays, user clicks Cancel again, message redisplays, user clicks Cancel a third time and message finally disappears. It's as if the If...Then statement has to loop twice to get to the second option and three times to get to the third option. Why is this happening...I don't follow the logic.
Code:
strMsg1 = "Click a button"
If MsgBox(strMsg1, vbYesNoCancel) = vbYes Then
'code A here
ElseIf MsgBox(strMsg1, vbYesNoCancel) = vbNo Then
'code B here
ElseIf MsgBox(strMsg1, vbYesNoCancel) = vbCancel Then
'do nothing
End If
Comment