H
Homer
I have a sheet that is protected so users can enter data is certain cells
without a password. When they do, when and who is tracked on another sheet.
The problem is, I want to be able to enter data in all cells. If I unprotect
the sheet, the code forces me to unprotect the sheet for each cell. Here is
the code I am using:
Private Sub Worksheet_Change(ByVal Target As Range)
Const PW As String = "my password"
ActiveSheet.Unprotect Password:=PW
If firstime = True Then
firstime = False
n = Sheets("changes").Cells(Rows.Count, 1).End(xlUp).Row + 1
Application.EnableEvents = False
Sheets("changes").Cells(n, 1).Value = Now
Sheets("changes").Cells(n, 2).Value = Environ("UserName")
Application.EnableEvents = True
End If
ActiveSheet.Protect Password:=PW
End Sub
without a password. When they do, when and who is tracked on another sheet.
The problem is, I want to be able to enter data in all cells. If I unprotect
the sheet, the code forces me to unprotect the sheet for each cell. Here is
the code I am using:
Private Sub Worksheet_Change(ByVal Target As Range)
Const PW As String = "my password"
ActiveSheet.Unprotect Password:=PW
If firstime = True Then
firstime = False
n = Sheets("changes").Cells(Rows.Count, 1).End(xlUp).Row + 1
Application.EnableEvents = False
Sheets("changes").Cells(n, 1).Value = Now
Sheets("changes").Cells(n, 2).Value = Environ("UserName")
Application.EnableEvents = True
End If
ActiveSheet.Protect Password:=PW
End Sub