+ Reply to Thread
Results 1 to 9 of 9

worksheet_change event stops working

Hybrid View

  1. #1
    Registered User
    Join Date
    05-02-2015
    Posts
    4

    worksheet_change event stops working

    Hello. There was a thread in 2013 that discussed my issue, but it ended in an argument over rules. So I'll ask it here:

    My worksheet change event macros stop working what seems to be randomly. If I close and reopen the workbook, they start working again. This does happen after a vba compiler error is triggered (I do have an on error control in the code). Please let me know what causes this or if you need more info. I can attach the code - which is only a few lines. Thanks!!

  2. #2
    Registered User
    Join Date
    05-02-2015
    Posts
    4
    Quote Originally Posted by kutach770 View Post
    Hello. There was a thread in 2013 that discussed my issue, but it ended in an argument over rules. So I'll ask it here:

    My worksheet change event macros stop working what seems to be randomly. If I close and reopen the workbook, they start working again. This does happen after a vba compiler error is triggered (I do have an on error control in the code). Please let me know what causes this or if you need more info. I can attach the code - which is only a few lines. Thanks!!
    My heading is:

    Sub worksheet_change (byval target as range)

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: worksheet_change event stops working

    Are you using
    Application.EnableEvents = False
    in your code? It is not being reset to True after that compile error.

    Press Ctrl+G to open immediate window and type ?Application.EnableEvents and press Enter. What do you get then, False or True?
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: worksheet_change event stops working

    Use Application.EnableEvents = True within the error handling code also.

  5. #5
    Registered User
    Join Date
    05-02-2015
    Posts
    4

    Re: worksheet_change event stops working

    BTW - I'm not sure about all the rules, but if someone figures out their own question (as the person did in the post I referred to above), they really should share their solution.

  6. #6
    Registered User
    Join Date
    05-02-2015
    Posts
    4

    Re: worksheet_change event stops working

    It worked! I deleted a dim statement to cause an error. After fixing it the procedure continued to work. I so appreciate it. Is there a thank you button or something I can do?

    For what it's worth, here's the code:

    Private Sub worksheet_change(ByVal target As Excel.Range)

    On Error GoTo ErrorHandler


    Dim DRange As Range
    Dim PRange As Range


    Set DRange = Range("Dool")
    Set PRange = Range("Pool")

    Application.EnableEvents = False

    If Not Intersect(target, DRange) Is Nothing Then

    target.Offset(0, 1) = target / target.Offset(0, -1)
    If (target.Offset(0, 2) > 0) Or (Me.Range("errdollar") > 1) Then
    MsgBox "Your proposed amount is below minimums", vbCritical

    End If


    ElseIf Not Intersect(target, PRange) Is Nothing Then

    target.Offset(0, -1) = target * target.Offset(0, -2)

    End If



    Application.EnableEvents = True

    ErrorHandler:

    Resume Next
    Application.EnableEvents = True

    End Sub

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: worksheet_change event stops working

    Its good to share the solution as it is helpful for other users who have the same issue.

    But unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Edit your post#5, highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    After adding the code tags, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

    You may also say thanks to those who have put their time and efforts to help you in this forum by clicking the Add Reputation link under their posts, another way to say thanks.

  8. #8
    Registered User
    Join Date
    04-09-2015
    Location
    USA
    MS-Off Ver
    Various.
    Posts
    2

    Re: worksheet_change event stops working

    I also had this issue of Worksheet_Change randomly not working. I finally found the problem. It was the ID-10-T error. I was debugging the code, and the compiler was still stopped at a breakpoint. I made a change in the code, and switched back to the worksheet to change a cell and fire the event again. And - Voila! - Nothing! But of course it did not fire because the debugger was still running from before. So I stopped the debugger and the event started working again.

  9. #9
    Registered User
    Join Date
    04-09-2015
    Location
    USA
    MS-Off Ver
    Various.
    Posts
    2

    Re: worksheet_change event stops working

    I also had this issue of Worksheet_Change not working, but it was random. I was starting to suspect the compiled code had become corrupt, but I eventually found the problem. It was a silly mistake on my part.

    I was debugging the code, and left the debugger running. I changed the code and switched back to the worksheet to make the event fire again. And - Voila! - Nothing! But of course it did not fire because the event was still stopped in the debugger from before. So I stopped the debugger and it started working again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Worksheet_Change event - second part not working since Target is already being defined
    By ther3cruit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2015, 04:01 PM
  2. Worksheet_Change event
    By serge.pigeot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2012, 03:20 AM
  3. Private Sub Worksheet_Change stops working when I have certain workbooks open.
    By forth250 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-12-2008, 03:47 PM
  4. Worksheet_Change event not working on xl2003
    By matrex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-29-2008, 12:38 PM
  5. [SOLVED] Event sometimes stops firing?
    By HotRod in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-04-2005, 08:06 PM

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