Hi all
I have no experience whatsovever with VBA, other than copy & paste existing code and adapt it a little through lots of googling... However I run into a problem now I cannot solve.
I want to keep track of changes in an excel document, so I use below code. Works fine, except when it has to deal with merged cells. Changes in a single cell are shown as "was changed from" OldVal "to" NewVal. But in case of a merged cell OldVal is never shown, hence I cannot see it was changed and the new input, but not the previous value in the merged cell.
Anyone knows how to deal with this (and please consider me as a simpleton VBA wise)
Thanks a lot!
Public OldVal As String Public NewVal As String Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub OldVal = Target.Value End Sub Private Sub Worksheet_Change(ByVal Target As Range) Dim LDate As String If Target.Cells.Count > 1 Then Exit Sub NewVal = Target.Value Application.EnableEvents = False Sheets("log").Cells(Rows.Count, "A").End(xlUp)(2).Value = Now & " / Cell " & Target.Address(0, 0) & " was changed from " & OldVal & " to " & NewVal & "" & " by " & Application.UserName Application.EnableEvents = True OldVal = "" NewVal = "" Application.EnableEvents = True End Sub
Bookmarks