Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does

Awesome, thanks to all that responded- This looks like it will solve my
problem.
Best,
Keith

"Rick Rothstein" wrote in message
...
You would use the EnableEvents property of the Application object. Here is
one of the many way to structure it...

Private Sub Worksheet_Change(ByVal Target As Range)
If <Your_Test_Condition = True Then
On Error GoTo CleanUp
Application.EnableEvents = False
'
' <<Your code goes here
'
End If
CleanUp
Application.EnableEvents = True
End Sub

Note: The On Error trap is needed in case your code errors out... if you
don't turn the EnableEvents back on, it remains off for other macros that
may be executed afterwards.

--
Rick (MVP - Excel)


"ker_01" wrote in message
...
I have two cells with data validation (each using a named range/list that
brings in data from another sheet).

When one changes, it runs through my code and works just fine.

When the other data validation changes, one of the things I have to do is
re-set the other data validation cell to the default value. This part is
working fine, except that it triggers the worksheet_change event to run a
second time.

Is there an elegant way to catch/ignore the worksheet_change event when
changes are caused by code instead of user interaction?

Thanks,
Keith




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
Trigger Event Code Shawn Excel Programming 2 July 14th 05 02:33 PM
Code to trigger drop down-select event Excel User Excel Programming 1 February 10th 05 07:22 PM
Code WAY too slow... (worksheet_change event) [email protected] Excel Programming 0 January 11th 05 08:34 PM


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