also it nearly crashes my pc (512mb ram) - I think because the sheet that I want to log changes on is , pre any other user intervention, created from scratch every time (ie its data is wiped, and refreshed by a seperate macro) -usually about 1000 rows and 20 columns -and its going to try and log this every time.
well that would have been worth knowing... I suppose the thing to do would be to have the sheet_change code conditional and set a boolean at the start and end of this other macro
'workbook_open or whereever the workbook is set up
Dim LogChanges As Boolean
LogChanges = False
'initialize worksheet
LogChanges = True
Private Sub Worksheet_Change(ByVal Target As Range)
If LogChanges = True Then
WriteToLog Now, ThisWorkbook.Name, ActiveSheet.Name, Target.Address, CStr(Target.Value), Environ("USERNAME")
End If
End Sub
You can also similarly select which cell changes you log
Private Sub Worksheet_Change(ByVal Target As Range)
' only log changes to column C
If LogChanges = True And Target.Column = 3 Then
WriteToLog Now, ThisWorkbook.Name, ActiveSheet.Name, Target.Address, CStr(Target.Value), Environ("USERNAME")
End If
End Sub