Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
Dim lngLZ As Long
Dim rngZelle As Range
On Error GoTo Fehler
If Sh.CodeName <> "wksDoku" Then
Application.EnableEvents = False
With wksDoku
lngLZ = .Cells(1, 1).End(xlDown).Row + 1
If lngLZ > Rows.Count Then
Call NeuesProtokoll
lngLZ = .Cells(Rows.Count, 1).End(xlUp).Row + 1
End If
.Cells(lngLZ, 2) = ActiveSheet.Name
.Cells(lngLZ, 3) = ActiveSheet.CodeName
.Cells(lngLZ, 6) = Environ("Username")
.Cells(lngLZ, 7) = Environ("Computername")
.Cells(lngLZ, 8) = ThisWorkbook.FullName
For Each rngZelle In Target
.Cells(lngLZ, 1) = Now
.Cells(lngLZ, 4) = rngZelle.Address(False, False)
If rngZelle.Value = "" Then
.Cells(lngLZ, 5) = "< Inhalt entfernt >"
Else
.Cells(lngLZ, 5) = rngZelle.Value
End If
lngLZ = lngLZ + 1
If lngLZ > Rows.Count Then
Call NeuesProtokoll
lngLZ = .Cells(Rows.Count, 1).End(xlUp).Row + 1
End If
Next
End With
Application.EnableEvents = True
End If
Exit Sub
Fehler:
lngLZ = wksDoku.Cells(1, 1).End(xlDown).Row + 1
If lngLZ > Rows.Count Then
Call NeuesProtokoll
lngLZ = wksDoku.Cells(Rows.Count, 1).End(xlUp).Row + 1
End If
With wksDoku
.Cells(lngLZ, 1) = Now
.Cells(lngLZ, 2) = "Err.Number: " & Err.Number
.Cells(lngLZ, 3) = "Err.Description: " & Err.Description
End With
lngLZ = wksDoku.Cells(1, 1).End(xlDown).Row + 1
If lngLZ > Rows.Count Then
Call NeuesProtokoll
lngLZ = wksDoku.Cells(Rows.Count, 1).End(xlUp).Row + 1
End If
Resume Next
End Sub
Private Sub NeuesProtokoll()
With wksDoku
.Range(.Cells(3, 1), .Cells(Rows.Count, Columns.Count)).Clear
.Cells(3, 1) = Now
.Cells(3, 2) = "ALTES PROTOKOLL GELÖSCHT!!!"
End With
End Sub
|