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
 

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

Back
Top