Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default suspend a routine

The code below calls a userform any time a cell is selected within that
range and it works fine, but, the routine which is triggered by a button on
the userform also selects a cell within that range causing the userform to
reappear. Is there any way to suspend that code while the macro runs its
course?


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Not Application.Intersect(Target, Range("A5:A200")) Is Nothing Then
Path_Of_Action.Show

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default suspend a routine

in your userform code:

Application.EnableEvents = False
'your selection line here
Application.EnableEvents = True

In article ,
"Patrick Simonds" wrote:

The code below calls a userform any time a cell is selected within that
range and it works fine, but, the routine which is triggered by a button on
the userform also selects a cell within that range causing the userform to
reappear. Is there any way to suspend that code while the macro runs its
course?


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Not Application.Intersect(Target, Range("A5:A200")) Is Nothing Then
Path_Of_Action.Show

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default suspend a routine

You could probably remove the select statement from your code as selects are
rarely required. That beind said you can suspend the events from firing if
you want something like this (always use an error handler when you toggle
application level settings)...

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
on error goto errorhandler
application.enableevents = false 'turn off events
If Not Application.Intersect(Target, Range("A5:A200")) Is Nothing Then
Path_Of_Action.Show

ErrorHandler:
application.enableevents = true 'turn events back on...
End Sub

--
HTH...

Jim Thomlinson


"Patrick Simonds" wrote:

The code below calls a userform any time a cell is selected within that
range and it works fine, but, the routine which is triggered by a button on
the userform also selects a cell within that range causing the userform to
reappear. Is there any way to suspend that code while the macro runs its
course?


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Not Application.Intersect(Target, Range("A5:A200")) Is Nothing Then
Path_Of_Action.Show

End Sub



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
suspend auto increment Bill Johnson Excel Discussion (Misc queries) 6 February 8th 08 06:26 PM
Suspend Execution Kaval Excel Programming 1 August 11th 05 09:21 AM
Suspend macro while others are running Simon Shaw Excel Programming 4 March 21st 05 03:01 PM
Suspend code John Excel Programming 0 August 18th 04 03:15 PM
Screen suspend eyecalibrate[_3_] Excel Programming 2 March 3rd 04 04:44 PM


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