Refering to this link : Automatic date update in a cell when another cell's value changes (as calculated by a formula)
Answer from Roman Is Helpful. but instead to store the oldvalue & oldDate to document properties, I'd prefer to store them in cell (table) within the same row.
here is what I try to change the function:
Public Function UDF_EditDate(ByVal newData As Range, ByRef oldData As Range, ByRef oldDate As Range) As Date
If newData.Count = 1 And oldData.Count = 1 And oldDate.Count = 1 Then
If (oldDate.Value = "") Or (newData.Value <> oldData.Value) Then
oldData.Value = newData.Value
Range(oldDate).Value = Now()
End If
UDF_EditDate = Now()
End If
End Function
and in the formula cell let say "D1" I put:
= UDF_EditDate(A1,B1,C1)
But, Unfortunately, this function doesn't work as expected.
any one could help me review and solve my problem?
The code below watches column A on a sheet, and when it is changed puts current date to the same row column B:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Target.Parent.Range("A:A")) Is Nothing Then Exit Sub
Target.Next.Value = Date
End Sub
This will work correctly only if single cell is changed, try to modify it for multiple yourself
Thanks to avb
I did slight modification for extended number of column A to D and put the update on Column E for the corresponded row.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Target.Parent.Range("A:D")) Is Nothing Then Exit Sub
For Each x In Target
Cells(x.Row, 5).Value = Now
Next
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.