ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   msg box to clear a sheet (https://www.excelbanter.com/excel-programming/350422-msg-box-clear-sheet.html)

Curt D.

msg box to clear a sheet
 
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

Gary Keramidas

msg box to clear a sheet
 
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

--


Gary


"Curt D." wrote in message
...
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




Curt D.

msg box to clear a sheet
 
Thanks that did it.

"Gary Keramidas" wrote:

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

--


Gary


"Curt D." wrote in message
...
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






All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com