Mega Code Archive
Using the Select Case Statement to check the MsgBox button clicked
Sub TestButtons()
Dim question As String
Dim bts As Integer
Dim myTitle As String
Dim myButton As Integer
question = "Do you want to preview the report now?"
bts = vbYesNoCancel + vbQuestion + vbDefaultButton1
myTitle = "Report"
myButton = MsgBox(prompt:=question, Buttons:=bts, Title:=myTitle)
Select Case myButton
Case 6
MsgBox "You can review the report now."
Case 7
MsgBox "You can review the report later."
Case Else
MsgBox "You pressed Cancel."
End Select
End Sub