Forum Discussion

fwreden's avatar
fwreden
Copper Contributor
Oct 26, 2025

Excel/VBA Worksheet_Change function running old version

I wrote a Worksheet_Change function initially. It worked. If I entered an incorrect value I got an error message, let's say the msgbox said "Error: A".  Then I changed the error message to read "Error B".  No matter what I have tried to do, rename the sheet, Debug>Compile VBA Project, etc, nothing can remove the old error message from appearing.  I have tried every suggestion Copilot has made without success.  I rebooted my machine.  I am using Microsoft Office for Home and Student 2021 running on Windows 11 Pro.  Does anyone know what might be the matter? Microsoft chat was totally useless and I am pretty sure Copilot is masquerading as a human in chat support because the wording and suggestions mirrored exactly what I encountered with Copilot, so that was a giant waste of my time.  If there's anyone who can help, I would welcome hearing from you with suggestions. 

1 Reply

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    What you’re experiencing is almost always not Excel showing a ghost old version, but rather some subtle issue with how the Worksheet_Change event is being triggered or where the code actually resides.

    You can add a simple Debug.Print to confirm exactly which code is running:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Debug.Print "Worksheet_Change fired"
        MsgBox "Error B"
    End Sub

    If you see "Worksheet_Change fired", the code is being executed.

    If you still see “Error: A”, then some other code or add-in is interfering.

     

    Otherwise it would be helpful if the VBA code was included.

Resources