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.
|