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
|