Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:12:41+00:00 2026-06-10T04:12:41+00:00

Worksheet_Change triggers when a cell value is changed (which is what I want), but

  • 0

Worksheet_Change triggers when a cell value is changed (which is what I want), but it also triggers when you enter a cell as if to edit it but don’t actually change the cell’s value (and this is what I don’t want to happen).

Say I want to add shading to cells whose value was changed. So I code this:

Private Sub Worksheet_Change(ByVal Target As Range)
    Target.Interior.ColorIndex = 36
End Sub

Now to test my work: Change cell A1 and the cell gets highlighted. That’s the desired behaviour. So far so good. Then, double click B1 but don’t change the value there and then click C1. You’ll notice B1 gets highlighted! And this is not the desired behaviour.

Do I have to go through the methods discussed here of capturing the old value, then compare old to new before highlighting the cell? I certainly hope there’s something I’m missing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:12:42+00:00Added an answer on June 10, 2026 at 4:12 am

    I suggest automatically maintaining a “mirror copy” of your sheet, in another sheet, for comparison with the changed cell’s value.

    @brettdj and @JohnLBevan essentially propose doing the same thing, but they store cell values in comments or a dictionary, respectively (and +1 for those ideas indeed). My feeling, though, is that it is conceptually much simpler to back up cells in cells, rather than in other objects (especially comments, which you or the user may want to use for other purposes).

    So, say I have Sheet1 whose cells the user may change. I created this other sheet called Sheet1_Mirror (which you could create at Workbook_Open and could set to be hidden if you so desire — up to you). To start with, the contents of Sheet1_Mirror would be identical to that of Sheet1 (again, you could enforce this at Workbook_Open).

    Every time Sheet1‘s Worksheet_Change is triggered, the code checks whether the “changed” cell’s value in Sheet1 is actually different from that in Sheet1_Mirror. If so, it does the action you want and updates the mirror sheet. If not, then nothing.

    This should put you on the right track:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r As Range
        For Each r In Target.Cells
            'Has the value actually changed?
            If r.Value <> Sheet1_Mirror.Range(r.Address).Value Then
                'Yes it has. Do whatever needs to be done.
                MsgBox "Value of cell " & r.Address & " was changed. " & vbCrLf _
                    & "Was: " & vbTab & Sheet1_Mirror.Range(r.Address).Value & vbCrLf _
                    & "Is now: " & vbTab & r.Value
                'Mirror this new value.
                Sheet1_Mirror.Range(r.Address).Value = r.Value
            Else
                'It hasn't really changed. Do nothing.
            End If
        Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function which is trying to detect when a particular cell value
I want to add some VBA code when the value in a cell changes.
The below macro is pulling a value from a cell which is referencing a
I'd like to have the value of a cell change if a specific set
I currently have this code : Private Sub Worksheet_Change(ByVal Target As Range) Dim lastrow
I currently have this code Private Sub Worksheet_Change(ByVal Target As Range) WorksheetChanged(Target, Range(AB3).CurrentRegion, Range(B18:B19))
I was using this routine, triggered by the Worksheet_Change event, to display a selected
All I'm trying to do is figure out how to change the cell in
I am trying to use the Worksheet Change Event in Excel VBA, but it
I have this code and i want do filter the autofill results by two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.