Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Worksheet_Change or Worksheet_SelectionChange

How do I keep Worksheet_Change from getting caught in a loop.

I use this Worksheet Event for a User to enter their ID in a Cell, the
program actually queries a database and returns records that fill into 4
other cells. When I debug the code I notice it gets caught in a loop.
When the records fill into the 4 cells, the Worksheet_Change is triggered
and it goes round and round. How do I stop this? I get the same problem
with Worksheet_SelectionChange. Please help. Much thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Worksheet_Change or Worksheet_SelectionChange

Disable events while your code is running eg

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False

'do whatever

ErrorHandler:
Application.EnableEvents = True
End Sub

Hope this helps
Rowan

Bret wrote:
How do I keep Worksheet_Change from getting caught in a loop.

I use this Worksheet Event for a User to enter their ID in a Cell, the
program actually queries a database and returns records that fill into 4
other cells. When I debug the code I notice it gets caught in a loop.
When the records fill into the 4 cells, the Worksheet_Change is triggered
and it goes round and round. How do I stop this? I get the same problem
with Worksheet_SelectionChange. Please help. Much thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Worksheet_Change or Worksheet_SelectionChange

Application.EnableEvents = False

code to enter data

Application.EnableEvents = True

--
Regards,
Tom Ogilvy

"Bret" wrote in message
...
How do I keep Worksheet_Change from getting caught in a loop.

I use this Worksheet Event for a User to enter their ID in a Cell, the
program actually queries a database and returns records that fill into 4
other cells. When I debug the code I notice it gets caught in a loop.
When the records fill into the 4 cells, the Worksheet_Change is triggered
and it goes round and round. How do I stop this? I get the same problem
with Worksheet_SelectionChange. Please help. Much thanks.




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
Worksheet_SelectionChange mangesh_yadav[_144_] Excel Programming 0 October 25th 04 12:56 PM
Worksheet_SelectionChange mangesh_yadav[_143_] Excel Programming 1 October 25th 04 11:49 AM
Worksheet_SelectionChange Rasmus[_2_] Excel Programming 2 June 27th 04 07:19 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 01:03 AM.

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

About Us

"It's about Microsoft Excel"