Home |
Search |
Today's Posts |
#2
![]() |
|||
|
|||
![]()
Jeff,
A simpler code version might be the answer. Give this a try... '------------------------------------------------- Sub RemoveSubtotals() On Error GoTo handleCancel Application.EnableCancelKey = xlErrorHandler If ActiveSheet.ProtectContents Then MsgBox "Please unprotect the sheet. ", vbInformation, _ " Remove Subtotals Program" Exit Sub End If Application.StatusBar = "REMOVING SUBTOTALS..." Application.ScreenUpdating = False Selection.RemoveSubtotal Application.StatusBar = False Application.ScreenUpdating = True Exit Sub handleCancel: Application.ScreenUpdating = True Application.StatusBar = False If Err.Number = 18 Then MsgBox "User interrupt occurred. Program will close. ", _ vbExclamation, " Remove Subtotals Program" Else MsgBox "Error Number: " & Err.Number & vbCrLf & Err.Description, _ vbCritical, " Remove Subtotals Program" End If End Sub '----------------------------------------------------------- Regards, Jim Cone San Francisco, USA "Jeff" wrote in message oups.com... Hi all, I have an xla application that includes a number of macros that I am trying to Error-proof. I am particularly interested in doing so because some other things I have going on in this app led me to employ some of Dave Peterson's LockWindowUpdate code (details in the code below). The first of the 3 macros below is an example of the macros I am trying to error-proof (& the only error I am really concerned with trapping is Error 18 which is supposed to be generated if the user cancels), the other two are supporting macros that might be invoked. I presently have coded for both Error 18 and Error 1004 (which is what actually gets generated when I [ESC] from this procedure when Removing Subtotals from a fairly large array of data). So the first of my two questions a 1) Can anyone can shed any light on why Error 18 isn't generated when the user presses [ESC]? and, more importantly, 2) When I execute this Remove Subtotals macro by stepping through it (with the help of a Breakpoint), the MsgBox DOES display, allowing the user to respond; but when I just run it from a toolbar button and press [ESC] while the Selection.RemoveSubtotal is executing (again, on a large enough array of data to let you press [ESC]), the macro just ends WITHOUT displaying any MsgBox. Can anyone help me understand why this works when stepping through it but not when executed normally? Thanks! Jeff code follows: - snip - |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
getting SCF code from ZIP Code | Excel Discussion (Misc queries) | |||
Help with Amending this Code Please | Excel Worksheet Functions | |||
Command Button VBA code | Excel Discussion (Misc queries) | |||
Often-Used Code not working in a new Workbook | Excel Discussion (Misc queries) | |||
Zip Code Macro | Excel Worksheet Functions |