Message Box

  • Thread starter Thread starter alish
  • Start date Start date
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
 
Dim resp as long
resp = msgbox(Prompt:="Are you sure", buttons:=vbyesno)
if resp = vbno then
'do nothing
else
activesheet.rows.delete
end if
 
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
 
Hi,

Note also that you can simplify the code to

Cells.Clear

Cheers,
Shane Devenshire
Microsoft Excel MVP

You are automatically prompted
 
Back
Top