Frage

Suppose there are two Worksheet 1, Worksheet 2. Both the Worksheets are have a 'Number' Column which ties the records together Workshhet 2 has 'Date' Column for each unique Number in the 'Number' column, Whenever Worksheet 2 'Date' column is changed i want to update a Column 'Times Changed' in Worksheet 1 for the unique Number in Worksheet 1 associated with the unique Number of Worksheet 2. Please help me guys! :)

I have tried the following

Private Sub Worksheet_Change(ByVal Target As Range) 
If Target.Address = "$A$1" Then [C5].Value = [C5].Value + 1 
End Sub
War es hilfreich?

Lösung

Your code should work within the same sheet. If you want to count the number of times the cell is changed in an other sheet, say Sheet2, then you would have to change the code to something like:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
        ActiveWorkbook.Sheets("Sheet2").Cells(Target.Row, 3).Value = ActiveWorkbook.Sheets("Sheet2").Cells(Target.Row, 3).Value + 1
    End If
End Sub

This change event only reacts on change to cells in A1:A100 and then changes the count in the corresponding cell in the C row on Sheet2.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top