msg box to clear a sheet

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top