Warning pop up window

J

JeffK

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
 
M

Mike H

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.
 
C

Chip Pearson

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]
 
J

JeffK

Worked like a charm! Thanks Mike

Mike H said:
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.
 
J

JeffK

Thanks Chip, your's work great as well. Much appreciated.

Chip Pearson said:
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]


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
.
 

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

Similar Threads


Top