Thank you, Logit!
I actually made some changes too once I figured out how everything works. Thank you for your code, it works great!
Here is my version, the only difference is the order of the columns:
Option Explicit
Dim vOldVal 'Must be at top of module
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim bBold As Boolean
If Target.Cells.Count > 1 Then Exit Sub
If ActiveSheet.Name = "Audit" Then Exit Sub
'On Error Resume Next
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If IsEmpty(vOldVal) Then vOldVal = "Empty Cell"
bBold = Target.HasFormula
With Sheets("Audit")
If .Range("A1") = vbNullString Then
'.Range("A1:H1") = Array("Cell Changed", "Old Value", _
"New Value", "Old Formula", "New Formula", "Time of Change", "Date of Change", "User")
.Range("A1:E1") = Array("Cell Changed", "Previous Value", "New Value", "User", "Date and Time of Change")
End If
With .Cells(.Rows.Count, 1).End(xlUp)(2, 1)
.Value = ActiveSheet.Name & " : " & Target.Address
.Offset(0, 1) = vOldVal
With .Offset(0, 2)
If bBold = True Then
.ClearComments
.AddComment.Text Text:= _
"OzGrid.com:" & Chr(10) & "" & Chr(10) & _
"Bold values are the results of formulas"
End If
.Value = Target
.Font.Bold = bBold
End With
' .Offset(0, 3) = Time
' .Offset(0, 4) = Date
' .Offset(0, 5) = Application.UserName
.Offset(0, 3) = Application.UserName
'.Offset(0, 4) = Date
.Offset(0, 4) = Format(Now, "dd.mmm.yyyy hh:mm:ss")
End With
.Cells.Columns.AutoFit
End With
vOldVal = vbNullString
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
On Error GoTo 0
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
vOldVal = Target
End Sub
Bookmarks