ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorkSheet.Delete (https://www.excelbanter.com/excel-programming/308409-worksheet-delete.html)

Pokey*

WorkSheet.Delete
 
I've run into a problem about deleting sheets. I wrote
a "work around" whereby the unwanted sheet is moved to a
new workbook and the new workbook is closed without
saving it, but I just think there has to be a better way!

If I use VB to delete a worksheet, I do not know how to
prevent the system from asking to confirm delete. This
same message appears when you manually delete, by the
way. Does anyone know how to answer (or prevent from
showing) that message box using VB?

Thanks!



Ron de Bruin

WorkSheet.Delete
 
Hi Pokey

Try this

Sub test()
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Pokey*" wrote in message ...
I've run into a problem about deleting sheets. I wrote
a "work around" whereby the unwanted sheet is moved to a
new workbook and the new workbook is closed without
saving it, but I just think there has to be a better way!

If I use VB to delete a worksheet, I do not know how to
prevent the system from asking to confirm delete. This
same message appears when you manually delete, by the
way. Does anyone know how to answer (or prevent from
showing) that message box using VB?

Thanks!





Chip Pearson

WorkSheet.Delete
 
Use Application.DisplayAlerts = False to prevent the message box.
E.g.,

Application.DisplayAlerts = False
' delete the sheet
Application.DisplayAlerts = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pokey*" wrote in message
...
I've run into a problem about deleting sheets. I wrote
a "work around" whereby the unwanted sheet is moved to a
new workbook and the new workbook is closed without
saving it, but I just think there has to be a better way!

If I use VB to delete a worksheet, I do not know how to
prevent the system from asking to confirm delete. This
same message appears when you manually delete, by the
way. Does anyone know how to answer (or prevent from
showing) that message box using VB?

Thanks!





Pokey*[_2_]

WorkSheet.Delete
 
AWWESOME, THANKS!!!
-----Original Message-----
Hi Pokey

Try this

Sub test()
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Pokey*" wrote in message

...
I've run into a problem about deleting sheets. I wrote
a "work around" whereby the unwanted sheet is moved to

a
new workbook and the new workbook is closed without
saving it, but I just think there has to be a better

way!

If I use VB to delete a worksheet, I do not know how to
prevent the system from asking to confirm delete. This
same message appears when you manually delete, by the
way. Does anyone know how to answer (or prevent from
showing) that message box using VB?

Thanks!




.


Pokey*[_2_]

WorkSheet.Delete
 
AWWESOME, THANKS!!!
-----Original Message-----
Use Application.DisplayAlerts = False to prevent the

message box.
E.g.,

Application.DisplayAlerts = False
' delete the sheet
Application.DisplayAlerts = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pokey*" wrote in message
...
I've run into a problem about deleting sheets. I wrote
a "work around" whereby the unwanted sheet is moved to

a
new workbook and the new workbook is closed without
saving it, but I just think there has to be a better

way!

If I use VB to delete a worksheet, I do not know how to
prevent the system from asking to confirm delete. This
same message appears when you manually delete, by the
way. Does anyone know how to answer (or prevent from
showing) that message box using VB?

Thanks!




.



All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com