Tigerlili3
Technical User
I have some vba to log changes made to an Excel workbook. The changes are logged to a '.txt' file. Here is the code:
Right now, each time the contents of any cell is changed, an entry containing the sheet name, cell reference, and user name is logged to a '.txt' file. What I would like to do is only have the event log one entry per sheet per user. I don't want the cell by cell breakdown. I know I can remove the Target.Address to get rid of the cell reference, but it will still log the sheet name and user name each time a cell is changed. Is there a way to prevent it from logging more than once?
Thanks!
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Const LogFileName As String = "C:\MyFiles\Tracker.txt"
Dim FileNum As Integer
FileNum = FreeFile
Open LogFileName For Append As #FileNum
x = Sh.Name & "!" & Target.Address & " was changed by " & Application.UserName & "."
Print #1, x
Close #1
End Sub
Right now, each time the contents of any cell is changed, an entry containing the sheet name, cell reference, and user name is logged to a '.txt' file. What I would like to do is only have the event log one entry per sheet per user. I don't want the cell by cell breakdown. I know I can remove the Target.Address to get rid of the cell reference, but it will still log the sheet name and user name each time a cell is changed. Is there a way to prevent it from logging more than once?
Thanks!