You could load all your data into an array on Workbook Activate..
Private Sub Workbook_Activate()
LastRow = ActiveSheet.UsedRange.Rows.Count
LastCol = ActiveSheet.UsedRange.Columns.Count
Dim ArrBefore(LastRow, LastCol)
For a = 1 To LastRow
For b = 2 To LastCol
ArrBefore(a, b-1) = Cells(a, b).Value
Next
Next
End Sub
then on saving you could do you checks...
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
CurrentUser = application.UserName 'This is the Excel username
'CurrentUser = Environ("USERNAME") 'This is the system username
For a = 1 To LastRow
For b = 1 To LastCol
If ArrBefore(a, b) <> Cells(a, b+1).Value Then
MsgBox ("User " & CurrentUser & " changed record No" & Cells(a, 1).Text & " Column" & Str(b) & " from " & ArrBefore(a, b) & " to " & Cells(a, b).Value & " on " & Date)
End If
Next
Next
End Sub
I've just sent the information to a message box here but you could put it wherever you wanted.
Adding and deleting records is a little trickier as they could feasibly insert/delete any number of rows at any location, but you could probably work something out using the array. Check for array elements that no longer exist in the spreadsheet or ones that appear in the spreadsheet but not the array.
Bookmarks