ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Warning pop up window (https://www.excelbanter.com/excel-programming/439561-warning-pop-up-window.html)

JeffK

Warning pop up window
 
I have programmed a "clear worksheet" button on my page and I'd like to have
a warning window pop up to warn if the user wants to do this.

Private Sub ClearPage_Click()
Range ("A4:B6").Select
Selection.ClearContents
End Sub

Thanks for your help

Mike H

Warning pop up window
 
Hi,

Try this

Private Sub ClearPage_Click()
response = MsgBox("Are you sure you want to clear cells?", vbOKCancel)
If response < vbOK Then Exit Sub
Range("A4:B6").ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"JeffK" wrote:

I have programmed a "clear worksheet" button on my page and I'd like to have
a warning window pop up to warn if the user wants to do this.

Private Sub ClearPage_Click()
Range ("A4:B6").Select
Selection.ClearContents
End Sub

Thanks for your help


Chip Pearson

Warning pop up window
 
Try

Sub ClearPage_Click()
If MsgBox("Are You Sure?",vbYesNo) = vbNo Then
Exit Sub
End If
' code to clear the sheet
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]


On Mon, 15 Feb 2010 10:31:02 -0800, JeffK
wrote:

I have programmed a "clear worksheet" button on my page and I'd like to have
a warning window pop up to warn if the user wants to do this.

Private Sub ClearPage_Click()
Range ("A4:B6").Select
Selection.ClearContents
End Sub

Thanks for your help


JeffK

Warning pop up window
 
Worked like a charm! Thanks Mike

"Mike H" wrote:

Hi,

Try this

Private Sub ClearPage_Click()
response = MsgBox("Are you sure you want to clear cells?", vbOKCancel)
If response < vbOK Then Exit Sub
Range("A4:B6").ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"JeffK" wrote:

I have programmed a "clear worksheet" button on my page and I'd like to have
a warning window pop up to warn if the user wants to do this.

Private Sub ClearPage_Click()
Range ("A4:B6").Select
Selection.ClearContents
End Sub

Thanks for your help


JeffK

Warning pop up window
 
Thanks Chip, your's work great as well. Much appreciated.

"Chip Pearson" wrote:

Try

Sub ClearPage_Click()
If MsgBox("Are You Sure?",vbYesNo) = vbNo Then
Exit Sub
End If
' code to clear the sheet
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]


On Mon, 15 Feb 2010 10:31:02 -0800, JeffK
wrote:

I have programmed a "clear worksheet" button on my page and I'd like to have
a warning window pop up to warn if the user wants to do this.

Private Sub ClearPage_Click()
Range ("A4:B6").Select
Selection.ClearContents
End Sub

Thanks for your help

.



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

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