+ Reply to Thread
Results 1 to 4 of 4

Validation code

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007/10
    Posts
    2

    Validation code

    Hi -- can someone definitively answer true or false? Application.EnableEvents=False is not effective when dealing with changes effected from within Range.Validation?

    I am manipulating lists within the Validation object, with EnableEvents set to False (repeatedly); nevertheless when I make the changes to the criteria it triggers changes attached to the WkshtChange code.

    I need to bring all triggersto a halt while I make changes via code... any thoughts?

    Thanks --

    Feckless in Seattle

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Validation code

    Could you post your code showing what you are doing
    when dealing with changes effected from within Range.Validation
    If you are using forms then the answer is no. From within a module it should. If you could post your code that triggers worksheet_change event and confirm that code is within a module and not a form
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    01-24-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007/10
    Posts
    2

    Re: Validation code

    I appreciate the response. The answer is I am not using a form, only setting validation rules within several cells on a sheet, triggered by a change in upline cells. The result is like a bullet ricocheting around the worksheet, changing cell values based on newly updated validation rules (after I have set Application.EnableEvents=False.)

    Let me see if I can get some clean code in here... it is spread out amongst several Subs...

  4. #4
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Validation code

    Your worksheet_change event should be denied when having "Appliciation.enableEvents = False"
    Any routines that contain such event trigger do not apply when you run EnableEvents = False.
    The effect also works works trough other workbooks. and after reopening excel.

    (When i am not sure i always make small excamples for my self to test them out what they do)

  5. #5
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Validation code

    An event is raised when the action that initiates the event occurs and the application automatically signals to all the components connected to object generating the event. The problem can be especially with worksheet_selectionChange event in that multiple events can be raised BEFORE you can turn off events (with Application.EnableEvents = False). Turning off events prevents further events downstream being raised not preventing upstream events that have already been raised. There is one other way of preventing a runaway loop of events by setting a Public Variable and testing that variable (usually a boolean) in the various events and use this to prevent events firing like a "bullet ricocheting around the worksheet"
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1