NeilBarn1701
New Member
- Joined
- Aug 8, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi, I hope someone can help me with this issue.
I need to create a timesheet for staff to complete (see attached)
In cell AI19 where at present the word 'Manager' sits the line manager will change this word to his initials.
After this is entered I would like the cells that correspond to that week e.g. A4:AC17 to lock so they can't be adjusted by the user.
This is then repeated for the next week and so on.
I have cleared the worksheet of all protected cells and added the following VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("AI19") = "Manager" Then
Range("A4:AC17").Locked = False
ElseIf Range("AI19") = "NB" Then
Range("A4:AC17").Locked = True
End If
End Sub
However, when I protect the sheet and try and enter data with or without the cell AI19 having the word 'Manager' I get a VBA error Run Time error '1004' Unable to set the locked property of the Range class.
I have checked, their are merged cells but not in the range given any help would be much appreciated.
Thanks
Neil
I need to create a timesheet for staff to complete (see attached)
In cell AI19 where at present the word 'Manager' sits the line manager will change this word to his initials.
After this is entered I would like the cells that correspond to that week e.g. A4:AC17 to lock so they can't be adjusted by the user.
This is then repeated for the next week and so on.
I have cleared the worksheet of all protected cells and added the following VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("AI19") = "Manager" Then
Range("A4:AC17").Locked = False
ElseIf Range("AI19") = "NB" Then
Range("A4:AC17").Locked = True
End If
End Sub
However, when I protect the sheet and try and enter data with or without the cell AI19 having the word 'Manager' I get a VBA error Run Time error '1004' Unable to set the locked property of the Range class.
I have checked, their are merged cells but not in the range given any help would be much appreciated.
Thanks
Neil