After deleting an Excel sheet with a button (control button from Control Toolbox not Button from Drawing) on it via VBA, all currently loaded forms unload, as if I hit the 'STOP' execution button from the editor. Deleting the sheet manually causes no such reaction. Execution only seems to stop when the sheet being deleted contains an object from the Control Toolbox; objects from the Drawing toolbox have no problem.
Any ideas?
Details:
1) the sub which actually deletes the sheet is NOT connected to the sheet in any way save that it resides in the same workbook
2) the actual code is simply: WS.Delete (WS is the appropriate WS object)
3) Delete the sheet from the immediate window has the same effect (stops all execution). Code used: Sheets("SheetName"
.Delete (Answer "y" to 'Are you sure?')
4) the sheet being deleted contains several functions/subs and several button objects on it; deleting other sheets does not have the same effect (execution continues)
5) I've replicated this effect by creating a form in a new book with a single button deleting sheets(1); when sheets(1) has a Command Button, the form unloads; when sheets(1) doesn't, the form stays loaded; there's no problem in deleting sheets with Button objects on them (Drawing toolbar); in fact, I've only mentioned buttons here, but if a sheet has any object from the Control toolbox, it stops execution upon deletion
Anyone ever experienced this?
Is there a way around it? (without using drawing toolbar objects)
Is this just a 'feature' of Excel? (I tend to think not, since behavior is different from VBA vs. manual)
Any ideas?
Details:
1) the sub which actually deletes the sheet is NOT connected to the sheet in any way save that it resides in the same workbook
2) the actual code is simply: WS.Delete (WS is the appropriate WS object)
3) Delete the sheet from the immediate window has the same effect (stops all execution). Code used: Sheets("SheetName"
4) the sheet being deleted contains several functions/subs and several button objects on it; deleting other sheets does not have the same effect (execution continues)
5) I've replicated this effect by creating a form in a new book with a single button deleting sheets(1); when sheets(1) has a Command Button, the form unloads; when sheets(1) doesn't, the form stays loaded; there's no problem in deleting sheets with Button objects on them (Drawing toolbar); in fact, I've only mentioned buttons here, but if a sheet has any object from the Control toolbox, it stops execution upon deletion
Anyone ever experienced this?
Is there a way around it? (without using drawing toolbar objects)
Is this just a 'feature' of Excel? (I tend to think not, since behavior is different from VBA vs. manual)