webjoh
webjoh

Reputation: 23

Excel/VBA changing date when there are changes to the workbook

is it possible in Excel to insert today's date into a Workbook/sheet only when the data inside the sheet is changed.

So what I mean by this is that there is a workbook with several sheets and if somebody makes changes to this sheets I want to have my date updated that is in a specific cell. For better understanding lets just say that this cell is C5 of the first worksheet.

Thank you in advance

Upvotes: 0

Views: 431

Answers (1)

Shai Rado
Shai Rado

Reputation: 33672

Try the code below:

Private Sub Worksheet_Change(ByVal Target As Range)

' check that the cell changed is not "C5"
If Intersect(Target, Range("C5")) Is Nothing Then
    Application.EnableEvents = False

    Range("C5").Value = Date
End If
Application.EnableEvents = True

End Sub

Upvotes: 1

Related Questions