Hi jos,
I have two ways to go about it.
Take #1
Make a copy of your entries (as you type) into another range - discreetly set apart. and set the scrollarea to “hide” . (Better still, you can copy to a hidden worksheet).
The following Worksheet Change event will keep track as you desire (with some bells and whistles!).
Private Sub Worksheet_Change (ByVal Target as Excel.Range)
Dim V As Long
Application.EnableEvents = False
Set rng1 = Application.Union (Range ("a1: g1"), Range ("H: IV"))
Set rng = Application.Intersect (Target, rng1)
If Not rng is nothing then Exit Sub
V = Target.Offset (0, 12). Value
If Target.Offset (0, 12) = "" Then
With Range ("H" & Target.Row)
. Value = Target.Address & ": first entry by " & Application.UserName & " at " & Now ()
. ColumnWidth = 60
. Interior.ColorIndex = 33
End With
Target.Offset (0, 12). Value = Target.Value
Application.EnableEvents = True
Exit Sub
End If
Target.Offset(0, 12).Value = Target.Value
With Range("H" & Target.Row)
.Value = Target.Address & " changed from " & V & " to " & Target.Value & " by " & Application.UserName & " at " & Now()
.ColumnWidth = 60
.Interior.Color = vbYellow
End With
Application.EnableEvents = True
End Sub
Rem: place in WorkBook module:
Private Sub Workbook_Open()
Worksheets(1).ScrollArea = "A:I"
End Sub
Take#2
Alternately, you could copy your entries (again as you type) into “Cell Comments”. Then deploy the following WorkSheet Change event to keep tabs of the record history
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim X As String
Dim C As String
Application.EnableEvents = False
Set rng = Application.Intersect(Target, Range("a2:g65536"))
If Not rng Is Nothing Then
On Error Resume Next
C = Target.Comment.Text
If C = "" Then C = "<blank>"
Target.ClearComments
X = Target.Value
With Target
.AddComment.Text X
.Comment.Visible = False
.Interior.Color = vbRed
.Font.Color = vbWhite
End With
With Range("H" & Target.Row)
.Value = Target.Address & ": Old value " & C & " changed to " & Target.Value & " by " & Application.UserName & " at " & Now()
.Columns.AutoFit
.Interior.ColorIndex = 33
End With
End If
'Optional line of code
If C = "<blank>" Then Range("H" & Target.Row).Clear
Application.EnableEvents = True
End Sub
I would personally prefer Take #1 to Take #2, if because it is tidier.
See Attachments. Amend ranges to suit.
Bookmarks