Message Box

A

alish

All, below is the code that I use to delete contents of the open sheet. How
do I make it ask or show a message box with 'Yes' or 'No' asking to delet or
not? Thanks in advance.

Cells.Select
Selection.Delete Shift:=xlUp

End Sub
 
D

Dave Peterson

Dim resp as long
resp = msgbox(Prompt:="Are you sure", buttons:=vbyesno)
if resp = vbno then
'do nothing
else
activesheet.rows.delete
end if
 
A

alish

Thanks, Dave, it worked!

Dave Peterson said:
Dim resp as long
resp = msgbox(Prompt:="Are you sure", buttons:=vbyesno)
if resp = vbno then
'do nothing
else
activesheet.rows.delete
end if
 
S

Shane Devenshire

Hi,

Note also that you can simplify the code to

Cells.Clear

Cheers,
Shane Devenshire
Microsoft Excel MVP

You are automatically prompted
 
Top