Deleting sheets

  • Thread starter Thread starter ranswrt
  • Start date Start date
R

ranswrt

I have a procedure that deletes sheets from the workbook. The problem I have
is Excel has window pop up that asks if I still want to delete the sheet. If
I select cancel the procedure continues to run as if the sheet was deleted.
How do I stop the procedure if delete sheet is canceled or get the window not
to pop up?
Thanks
 
Application.DisplayAlerts = False
Sheets("Sheet 1").Delete
Application.DisplayAlerts = True

The above code should keep the message from appearing. If you let the
message pop up then you need to check if the sheet still exists after the
delete...
 
Thanks

Jim Thomlinson said:
Application.DisplayAlerts = False
Sheets("Sheet 1").Delete
Application.DisplayAlerts = True

The above code should keep the message from appearing. If you let the
message pop up then you need to check if the sheet still exists after the
delete...
 
You have to change the macro to something like...

'/--------------------------------------------------------/
varAnswer = MsgBox("Delete worksheet?", vbYesNo)

If varAnswer <> vbYes Then
Exit Sub
End If
'/--------------------------------------------------------/

--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown
 

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