Function whenChanged(pCell As Object) As Date
wMod = "Changed"
wSep = ";"
wDate = Date + Time
wtext = pCell.Text
wAd = pCell.Address
wWs = pCell.Worksheet.Name
If Worksheets(wWs).Range(wAd).Comment Is Nothing Then
Worksheets(wWs).Range(wAd).AddComment wSep & wSep
End If
wCom = Worksheets(wWs).Range(wAd).Comment.Text
wArr = Split(wCom, wSep)
If wArr(0) = "" Then
wNCom = wMod + wSep + Format(wDate, "YYYY-MM-DD HH:MM:SS") + wSep + wtext
Worksheets(wWs).Range(wAd).Comment.Visible = False
Worksheets(wWs).Range(wAd).Comment.Text wNCom
whenChanged = wDate
Else
If wArr(0) = wMod Then
If wtext = wArr(2) Then
whenChanged = CDate(wArr(1))
Else
wNCom = wMod + wSep + Format(wDate, "YYYY-MM-DD HH:MM:SS") + wSep + wtext
Worksheets(wWs).Range(wAd).Comment.Visible = False
Worksheets(wWs).Range(wAd).Comment.Text wNCom
whenChanged = wDate
End If
Else
MsgBox "You are about to erase a comment in cell " & wAd & ", you can not use function whenChanged here."
whenChanged = 0
End If
End If
End Function