BravoBravoAu
Board Regular
- Joined
- Nov 8, 2011
- Messages
- 64
- Office Version
- 2016
- Platform
- Windows
Based on some earlier advice from @Yongle, I've been using a worksheet to track progress on tasks, using the code below to record date, time and by who certain entries are made:
I'm now looking to protect the worksheet as it will be shared and some fields don't need most users to have access to them.
To do so, I expected I would have to modify each of the three above ranges to:
But I'm continuing to get "run-time error 1004". When I debug, the first line (date) is highlighted.
HELP?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 Then Exit Sub 'ignore changes in header row
If Target.Column = Range("K1").Column Then
Cells(Target.Row, "L") = Date
Cells(Target.Row, "M") = Time
Cells(Target.Row, "N") = Application.UserName
End If
If Target.Column = Range("R1").Column Then
Cells(Target.Row, "S") = Date
Cells(Target.Row, "T") = Time
Cells(Target.Row, "U") = Application.UserName
End If
If Target.Column = Range("V1").Column Then
Cells(Target.Row, "W") = Date
Cells(Target.Row, "X") = Time
Cells(Target.Row, "Y") = Application.UserName
End If
End Sub
I'm now looking to protect the worksheet as it will be shared and some fields don't need most users to have access to them.
To do so, I expected I would have to modify each of the three above ranges to:
Code:
If Target.Column = Range("K1").Column Then
ActiveSheet.Unprotect "PASSWORDHERE"
Cells(Target.Row, "L") = Date
Cells(Target.Row, "M") = Time
Cells(Target.Row, "N") = Application.UserName
ActiveSheet.Protect "PASSWORDHERE", True, True
End If
But I'm continuing to get "run-time error 1004". When I debug, the first line (date) is highlighted.
HELP?