Ryan Jacques
Ryan Jacques

Reputation: 3

Add a identifier if you change a cell value in a row

Is there a way in excel (VBA) to mark any change in a row (A2-A10) for example with an identifier if any cell in that row is changed. So for if A2 changes, add an X in A1

Upvotes: 0

Views: 73

Answers (2)

Error 1004
Error 1004

Reputation: 8230

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Count > 1 Then Exit Sub

        Application.EnableEvents = False

        If Not Intersect(Target, Range("A2:A10")) Is Nothing And Target <> "" Then '<- If there is any change in area A2:A10 and the value of the affect cell IS NOT empty then

            ThisWorkbook.Worksheets("Sheet1").Range("A1").Value = "X"

        ElseIf Not Intersect(Target, Range("A2:A10")) Is Nothing And Target = "" Then  '<- If there is any change in area A2:A10 and the value of the affect cell IS empty then

            ThisWorkbook.Worksheets("Sheet1").Range("A1").Value = ""

        End If

        Application.EnableEvents = True

End Sub

Upvotes: 1

D2_20
D2_20

Reputation: 1

You can have a macro function to change the value or add new value when anything changes in the source cell. This macro will be on the rows where the change needs to be recorded.

Upvotes: 0

Related Questions