+ Reply to Thread
Results 1 to 18 of 18

Worksheet Change not firing

  1. #1
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Worksheet Change not firing

    Can anyone shed some light on why this code won't work for me? Worksheet Change doesn't seem to fire when P3 becomes "13" or "43". It seems to work with Workbook Sheet Selection Change, but then the msgbox keeps popping up every time I click a cell/button after 13 or 43 is within the cell, I only wish for the msgbox to appear once.

    Please Login or Register  to view this content.
    Please note I have also tried Worksheet Calculate and this doesn't do anything either. I'm not getting any error messages or debugs.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Worksheet Change not firing

    Application.EnableEvents = 0
    put before the end of the code. If it is not firing, one way would be to re-start your PC(I know it is pain in the neck, but always do this way) and events would be then enabled.

  3. #3
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    OK so I changed my code to:

    Please Login or Register  to view this content.
    And I restarted my PC, but it still doesn't work?

    I have the code in Sheet1, is this correct?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, rachel.dudley,

    this wokred for me:
    Please Login or Register  to view this content.
    Due to the event raised the number needs to be changed by hand in irder to fire again.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    Could it be because P3 is a formula? (=sum(Q3:X3)) and the sum only gets generated once the value of F3 is input. I would then expect the msgbox to show up after the value of F3 has been input by the user, but so far I do not have this working.

    I have just tried your code also Holger, but this does not work for me. I think because you are inputting the value manually.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, rachel.dudley,

    like stated the Worksheet_Change only gets fired by direct entry. If itīs a formula you must either monitor the cells the target reflects on or use the Calcukate event for the check.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    I did try the calculate event but that did not seem to work either. I have also tried referencing the sum range instead of the target cell but that also didn't work.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, rachel.dudley,

    please run a check in the VBE in the Immediate Window about the state for the Application getting fired.
    Please Login or Register  to view this content.
    and hit Enter, True fires the events while False should be reversed by
    Please Login or Register  to view this content.
    And maybe attach a sample working book clarifying what you have and what you want to get - Iīm a bit lost on that by now.

    Ciao,
    Holger
    Last edited by HaHoBe; 03-26-2013 at 12:43 PM. Reason: feel like getting lost on typos :(

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Worksheet Change not firing

    Rachel,
    I did not notice on your code that your events should be the other way round. First False, or 0 and before the end it should be true, or 1

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, AB33,

    what use could be in turning on events that are fired and hope that when they are turned off at the end of the code they will get fired the next time?

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    Can I ask what the immediate window is?

  12. #12
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    Also, AB33, I switched them like you said, having false first and true after my code and that did not work either.

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Worksheet Change not firing

    Holger,
    Look at your code no 4 and look again on Rachel's original code. The events are not on the same direction

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, AB33,

    Quote Originally Posted by Ab33
    Application.EnableEvents = 0
    put before the end of the code.
    That turns the events off so they canīt get fired again (AFAIR 0 means False in VBA as well as in Excel itself). My code tries to take care of getting the events on again before the macro is left. It will only work if the events are on but I donīt get the idea why the events should be turned off if a value is changed directly in a cell unless something else/new is written into the very same cell (not happening here with this code) so it could and should be omitted.


    @rachel.dudley:
    A helpful place to check things out . Press CRTL+G when in the VBE.

    Ciao,
    Holger
    Last edited by HaHoBe; 03-26-2013 at 01:11 PM. Reason: zzzz! typos

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Worksheet Change not firing

    Holger,
    You are right!
    It was my mistake. Was meant to be 1

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Worksheet Change not firing

    Hi, AB33,

    AFAIK in VBA True is -1 while in Excel it is 1.

    Ciao,
    Holger

  17. #17
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    I'm totally confused with this now and still do not have working code.. This is what I currently have...

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Worksheet Change not firing

    Nevermind.. I started from scratch and this has worked for me..

    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)

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