LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Jim Cone
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting SCF code from ZIP Code Keith Radley Excel Discussion (Misc queries) 2 February 26th 05 10:08 PM
Help with Amending this Code Please [email protected] Excel Worksheet Functions 4 February 1st 05 07:04 PM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM
Often-Used Code not working in a new Workbook Steve Excel Discussion (Misc queries) 2 December 16th 04 11:55 PM
Zip Code Macro Ken Wright Excel Worksheet Functions 0 December 9th 04 07:55 AM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"