ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Worksheet Delete "Data may exist" (https://www.excelbanter.com/excel-programming/364384-excel-worksheet-delete-data-may-exist.html)

XidGarcia

Excel Worksheet Delete "Data may exist"
 
When I am attempting to delete a worksheet from a collection the
command is failing. I have disabled events, and re-enable them after I
delete the worksheets. For whatever reason, it is not completing the
delete operation. If I make the worksheet visible and enable the
events while debugging I can see the message box pop up saying data may
exist, click delete to delete permanently. I can hear the error beep
when the events are disabled. I am not sure what exaclty is going on
here, any help would be greatly appreciated. The code is below.

xlApp.EnableEvents = False
xlWb = xlApp.Workbooks.Add()

tempXlWb.worksheets("WAR Premium
Allocation").Copy(Befo=xlWb.Worksheets("Sheet1" ))

xlWb.Worksheets("Sheet1").Delete()
xlWb.Worksheets("Sheet2").Delete()
xlWb.Worksheets("Sheet3").Delete()

xlApp.EnableEvents = True


Don Guillett

Excel Worksheet Delete "Data may exist"
 
Application.DisplayAlerts = False

--
Don Guillett
SalesAid Software

"XidGarcia" wrote in message
ups.com...
When I am attempting to delete a worksheet from a collection the
command is failing. I have disabled events, and re-enable them after I
delete the worksheets. For whatever reason, it is not completing the
delete operation. If I make the worksheet visible and enable the
events while debugging I can see the message box pop up saying data may
exist, click delete to delete permanently. I can hear the error beep
when the events are disabled. I am not sure what exaclty is going on
here, any help would be greatly appreciated. The code is below.

xlApp.EnableEvents = False
xlWb = xlApp.Workbooks.Add()

tempXlWb.worksheets("WAR Premium
Allocation").Copy(Befo=xlWb.Worksheets("Sheet1" ))

xlWb.Worksheets("Sheet1").Delete()
xlWb.Worksheets("Sheet2").Delete()
xlWb.Worksheets("Sheet3").Delete()

xlApp.EnableEvents = True




MaryR

Excel Worksheet Delete "Data may exist"
 
Don't forget to set DisplayAlerts back to True when you're done deleting so
you can see if other alerts are relevant to what you're trying to accomplish.

--
--Being powerful is like being a lady; if you have to tell people you are,
you aren''t. ~~Margaret Thatcher


"Don Guillett" wrote:

Application.DisplayAlerts = False

--
Don Guillett
SalesAid Software

"XidGarcia" wrote in message
ups.com...
When I am attempting to delete a worksheet from a collection the
command is failing. I have disabled events, and re-enable them after I
delete the worksheets. For whatever reason, it is not completing the
delete operation. If I make the worksheet visible and enable the
events while debugging I can see the message box pop up saying data may
exist, click delete to delete permanently. I can hear the error beep
when the events are disabled. I am not sure what exaclty is going on
here, any help would be greatly appreciated. The code is below.

xlApp.EnableEvents = False
xlWb = xlApp.Workbooks.Add()

tempXlWb.worksheets("WAR Premium
Allocation").Copy(Befo=xlWb.Worksheets("Sheet1" ))

xlWb.Worksheets("Sheet1").Delete()
xlWb.Worksheets("Sheet2").Delete()
xlWb.Worksheets("Sheet3").Delete()

xlApp.EnableEvents = True





XidGarcia

Excel Worksheet Delete "Data may exist"
 
Worked great, thanks!



All times are GMT +1. The time now is 12:14 PM.

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