Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How auto EnableEvents again on code-break and errors?

When one hits "End" on a error in the code after a EnableEvents=false,
the complete programming has been finised!

So how can a automaticly re-enable the events?

I tryed using a sub with EnableEvents=True that get's executed with a
OnTime-event after the code has been finished, but this gives "Can't
execute code in break mode" while I'm debugging and programming.

Also if I go in break-mode while debugging, the last line that
re-enables the events isn't getting executed. This way I need to
enable the events manually before I can start debugging it again.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default How auto EnableEvents again on code-break and errors?

Michel

I don't think you can do it automatically. If I'm going to do it a lot, I
set up a sub like you and just run it after I exit debug mode. Otherwise, I
just use the Immediate Window.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Michel" wrote in message
om...
When one hits "End" on a error in the code after a EnableEvents=false,
the complete programming has been finised!

So how can a automaticly re-enable the events?

I tryed using a sub with EnableEvents=True that get's executed with a
OnTime-event after the code has been finished, but this gives "Can't
execute code in break mode" while I'm debugging and programming.

Also if I go in break-mode while debugging, the last line that
re-enables the events isn't getting executed. This way I need to
enable the events manually before I can start debugging it again.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How auto EnableEvents again on code-break and errors?

Did you really use End by itself?

If yes, maybe you can rewrite your code:

Here's a simple example:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

On Error GoTo errHandler:
With Target
If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = .Value / 3
End If
End With

errHandler:
Application.EnableEvents = True

End Sub

Michel wrote:

When one hits "End" on a error in the code after a EnableEvents=false,
the complete programming has been finised!

So how can a automaticly re-enable the events?

I tryed using a sub with EnableEvents=True that get's executed with a
OnTime-event after the code has been finished, but this gives "Can't
execute code in break mode" while I'm debugging and programming.

Also if I go in break-mode while debugging, the last line that
re-enables the events isn't getting executed. This way I need to
enable the events manually before I can start debugging it again.


--

Dave Peterson

Reply
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
ERRORS IN CODE 2003 Neil Holden Excel Discussion (Misc queries) 1 February 12th 10 09:43 AM
Errors in VB Code since adding macro Susan Excel Discussion (Misc queries) 1 April 11th 06 08:42 PM
VBA Code Errors PaulW Excel Discussion (Misc queries) 3 April 4th 06 01:21 PM
Calling a bit of code from a sheet errors gearoi Excel Discussion (Misc queries) 2 September 6th 05 08:21 PM
Remind me to set Error Trapping to Break on Unhandled Errors don Excel Programming 0 November 5th 03 06:06 PM


All times are GMT +1. The time now is 09:18 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"