Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
i_tab = "ilkimykset"
Sheets(i_tab).Select
If Err.Number <> 0 Then
Sheets.Add(After:=Sheets(Sheets.Count)).Name = i_tab
Sheets(i_tab).Visible = xlSheetVeryHidden
End If
With Sheets(i_tab)
.Unprotect
.Range("A:B").ClearContents
For Sh = 1 To Worksheets.Count
.Cells(Sh, 1) = Sheets(Sh).Name
.Cells(Sh, 2) = Sheets(Sh).ProtectContents
Next Sh
.Visible = xlSheetVeryHidden
.Protect
End With
ThisWorkbook.Save
Application.EnableEvents = True
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
With ActiveSheet
PC = .ProtectContents
i_tab = "ilkimykset"
asn = .Name
With Sheets(i_tab)
y = 0
Do
y = y + 1
Loop Until .Cells(y, 1) = asn Or .Cells(y, 1) = Empty
If .Cells(y, 1) = Empty Then .Cells(y, 1) = Ssh
If .Cells(y, 2) <> PC Then
.Unprotect
.Cells(y, 2) = PC
yc = .Cells(.Rows.Count, 3).End(xlUp).Row + 1
.Cells(yc, 3) = Now
.Cells(yc, 3).NumberFormat = "dd/mm/yy hh:mm:ss"
.Cells(yc, 4) = Application.UserName
.Cells(yc, 5) = asn
.Cells(yc, 6) = PC
.Cells(yc, 7) = Target.Address
.Protect
ThisWorkbook.Save
End If
End With
End With
Application.EnableEvents = True
End Sub
Private Sub Workbook_Activate()
Application.ScreenUpdating = False
Application.EnableEvents = False
With ActiveSheet
PC = .ProtectContents
i_tab = "ilkimykset"
asn = .Name
With Sheets(i_tab)
y = 0
Do
y = y + 1
Loop Until .Cells(y, 1) = asn Or .Cells(y, 1) = Empty
If .Cells(y, 1) = Empty Then .Cells(y, 1) = Ssh
If .Cells(y, 2) <> PC Then
.Unprotect
.Cells(y, 2) = PC
yc = .Cells(.Rows.Count, 3).End(xlUp).Row + 1
.Cells(yc, 3) = Now
.Cells(yc, 3).NumberFormat = "dd/mm/yy hh:mm:ss"
.Cells(yc, 4) = Application.UserName
.Cells(yc, 5) = asn
.Cells(yc, 6) = PC
.Protect
ThisWorkbook.Save
End If
End With
End With
Application.EnableEvents = True
End Sub