• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

add date time to audit trl.

akika

New Member
Hi,

how to amend this code .. to include date & time that the changes done to a workbook cell is performed??

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> PreviousValue Then
Sheets("details").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
Application.UserName & " changed cell " & Target.Address _
& " from " & PreviousValue & " to " & Target.Value
End If

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub

From
current output:
Akika YS changed cell $C$8 from 23 to 121

To Expected output:
12-Dec-18 Akika YS changed cell $C$8 from 23 to 121
 
Hi akika,
the function:
Code:
now()
Reads in the current time/date.
This can be formatted as a string with:
Code:
format()
So, something like:
Code:
format(now(),"dd-mmm-yy")
or
Code:
format(now(),"dd-mmm-yy hh:mm:ss")
Will produce what I think you are looking for.
You can concatenate this with your output string as normal.

If this was helpful, please click 'Like'!

Stevie
 
Back
Top