Consulting

Results 1 to 7 of 7

Thread: Worksheet_Change Event Won?t Trigger

  1. #1

    Worksheet_Change Event Won?t Trigger

    I must have 10 or 15 different workbooks that have Worksheet_Change events working just fine, but I am trying to set up a new workbook to have a Worksheet_Change event, and it just won?t trigger.

    I placed the following code into the module for worksheet ?Main?:
    [vba] Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox "Test " & Target
    End Sub[/vba] When I add a value to a cell in worksheet ?Main? or I change the value in a cell there, absolutely nothing happens. I have changed the cell value directly on the worksheet, and I have used a macro to change a cell value. Neither triggers the event. I included the statement
    Application.EnableEvents = True

    in the macro I executed just in case events were turned off. No help.
    I?m stumped. What am I missing??

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hi Sid,

    Have you tried running Application.EnableEvents = True in the immediates window?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    Yep, just did. No help. HOWEVER, I switched to another workbook I use for testing and duplicated the code, and it worked just fine. I went back to the original one, and it still doesn't work. Let's assume it's solved. Thanks Ken.

  4. #4
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    Wierd. Are you sure you pasted the code into the right worksheet? Seems to be the only reason it would not fire like the others.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  5. #5
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Sid,

    I find that if an error occurs, the code doesn't get to Application.EnableEvents = True and running it after the error doesn't enable events - I then have to exit the workbook completely to restore things...

    Regards,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sid,
    Here's a wee utlity I keep on a handy button for checking/resetting Events while debugging.
    Regards
    Malcolm

    [vba]
    Sub Enabled()
    Dim Chk as Boolean
    Chk = Application.EnableEvents
    MsgBox "Events enabled is " & Chk
    If Chk = False Then
    Application.EnableEvents = True
    Enabled
    End If
    End Sub

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hey, Malcolm!

    Great idea.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

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