There are times you may want users to click Yes or No. Just insert this line of code. Here the Select Case statement is used.
YesNo = MsgBox("This macro will ... Do you want to continue?", vbYesNo + vbCritical, "Caution")
Select Case YesNo
Case vbYes
'Insert your code here if Yes is clicked
Case vbNo
'Insert your code here if No is clicked
End Select
2 comments:
Don't forget to declare YesNo as a VbMsgBoxResult.
You could simplify this code even further by using an IF statement, for example:
If MsgBox("This macro will ... Do you want to continue?", vbYesNo + vbCritical, "Caution") = vbYes Then
' do something
Else
' do something else
End If
HTH,
JP
hi,
I need assistance with above mentioned eg,as this isn't working to well when i do a debug on my code i get the value 4 for vbyesno so this doesn't give me a true false value please look at my code below.
MsgBox "Are You sure you want to continue without refreshing PivotTable?", vbYesNo
If vbYesNo = False Then
pivot_update
Formulas_Insert
End If
vbyesno have a value of 4
Post a Comment