Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default SelectionChange stops working

Dear All,

I am testing some SelectionChange event code. Each time it doesn't like
like what I test it with it refuses to trigger the event again. My only
solution to get it working again is to save the file, close the
workbook, and close Excel.

I then have restart Excel and reopen the file to try it again. Is there
some 'reset' trick that saves me from having to go out of the
application altogether so I continue on?

Many thanks,

andym

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default SelectionChange stops working

Hi Andym,

It is possible that the code is turning of events with the line:

Application.EnableEvents = False

If the code fails, the corresponding re-activation of events is not taking
place.

Therefore, try changing your code to include an error handler which restores
the setting, e.g.:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo XIT
Application.EnableEvents = False

'your code
XIT:
Application.EnableEvents = True

End Sub
'<<=============


Immediately, however, restore the setting by typing:

Application.EnableEvents = True

in the Immediate window and hitting the Enter key.


---
Regards,
Norman


"andym" wrote in message
ups.com...
Dear All,

I am testing some SelectionChange event code. Each time it doesn't like
like what I test it with it refuses to trigger the event again. My only
solution to get it working again is to save the file, close the
workbook, and close Excel.

I then have restart Excel and reopen the file to try it again. Is there
some 'reset' trick that saves me from having to go out of the
application altogether so I continue on?

Many thanks,

andym



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default SelectionChange stops working

Thanks Norman,

this worked great!!

I have another question, but I will start up another post.

I appreciate your help.

Regards,

andym


Norman Jones wrote:
Hi Andym,

It is possible that the code is turning of events with the line:

Application.EnableEvents = False

If the code fails, the corresponding re-activation of events is not taking
place.

Therefore, try changing your code to include an error handler which restores
the setting, e.g.:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo XIT
Application.EnableEvents = False

'your code
XIT:
Application.EnableEvents = True

End Sub
'<<=============


Immediately, however, restore the setting by typing:

Application.EnableEvents = True

in the Immediate window and hitting the Enter key.


---
Regards,
Norman


"andym" wrote in message
ups.com...
Dear All,

I am testing some SelectionChange event code. Each time it doesn't like
like what I test it with it refuses to trigger the event again. My only
solution to get it working again is to save the file, close the
workbook, and close Excel.

I then have restart Excel and reopen the file to try it again. Is there
some 'reset' trick that saves me from having to go out of the
application altogether so I continue on?

Many thanks,

andym


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default SelectionChange stops working

Andy,
If there are errors in your code, then the IDE goes in to break mode with
the line highlighted.
At this point you can either correct the code or click the reset icon to
stop code execution.

You should not have go through all that to get working again, but then again
it may depend on what you're actually doing.

This may be a good time to introduce some error traps in your code to deal
with exceptions.

NickHK

"andym" wrote in message
ups.com...
Dear All,

I am testing some SelectionChange event code. Each time it doesn't like
like what I test it with it refuses to trigger the event again. My only
solution to get it working again is to save the file, close the
workbook, and close Excel.

I then have restart Excel and reopen the file to try it again. Is there
some 'reset' trick that saves me from having to go out of the
application altogether so I continue on?

Many thanks,

andym



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
IF just STOPS WORKING Gee Excel Worksheet Functions 21 August 6th 09 05:26 PM
Vlookup stops working??? Steve Peel Excel Worksheet Functions 0 September 19th 08 07:08 PM
Autofilter Stops Working Vliegveld Excel Worksheet Functions 7 September 7th 05 01:19 AM
VBA Stops Working? Marty Excel Programming 4 February 16th 05 05:27 PM
Hyperlink stops working Jami's Mom Excel Worksheet Functions 0 December 20th 04 05:17 PM


All times are GMT +1. The time now is 06:37 PM.

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"