Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Oct 27, 4:19*pm, Chip Pearson wrote:
Does the button that starts the delete process reside on the same sheet that is being deleted? That could cause a problem. You can use Application.OnTime to delete that sheet, and the code execution will be deferred until Excel is ready to do it. E.g, '[in the sheet's code module] Sub Button1_Click() * * * * Application.OnTime Now,"DeleteSheet",,True End Sub '[in a regular code module] Sub DeleteSheet() * * * * Application.DisplayAlerts = False * * * * Worksheets(1).Delete * * * * Application.DisplayAlerts = True End Sub I think you're right. I think the reason I was getting an error was because I was trying to delete a worksheet that had remaining code left to execute. I fixed it by moving the remaining code to a code module but it sounds like the "OnTime" method is the way to go. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting Worksheet in excel = 2003 / 2007 | Excel Worksheet Functions | |||
Excel 2003 converted to 2007 copying worksheet error | Excel Discussion (Misc queries) | |||
-2147417848 Error Code - Deleting a Worksheet using VBA | Excel Programming | |||
Deleting Worksheet Error | Excel Programming | |||
error runtime 9: deleting a worksheet | Excel Programming |