Thursday, March 10, 2011

How to make a Yes or No macro in Excel

There may be times when your Excel spreadsheet will want users to click a "Yes" or "No" button. To do this simply insert this line of VBA code. Tthe Select Case statement is used in this example.
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