msg box to clear a sheet

G

Guest

I need a msg box that has a yes and no button that ask if you want to clear
the sheet. If yes then continue to run the macro and if no then to stop at
that point. any help is appreciated. thanks
 
G

Gary Keramidas

change the range to suit your needs

Sub Clear_Sheet()
Select Case MsgBox("Are you sure you want to clear all data?", _
vbYesNo Or vbQuestion Or vbDefaultButton1, Application.Name)

Case vbYes
ActiveSheet.Range("B3:O65,Q3:Q65").ClearContents

Case vbNo

End Select
End Sub
 
G

Guest

Thanks that did it.

Gary Keramidas said:
change the range to suit your needs

Sub Clear_Sheet()
Select Case MsgBox("Are you sure you want to clear all data?", _
vbYesNo Or vbQuestion Or vbDefaultButton1, Application.Name)

Case vbYes
ActiveSheet.Range("B3:O65,Q3:Q65").ClearContents

Case vbNo

End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top