WatfordKev
Board Regular
- Joined
- Mar 30, 2011
- Messages
- 78
I've read as much as I can on this but to little avail.
I have a Workbook which I want to update in VB code. It's on a protected sheet, which I unprotect, make the changes, protect again and this all seems to work until I then want to unlock a few cells for my colleagues to have access too.
Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
ActiveSheet.Unprotect "password"
If Range("D80").Value >= "Green" Then
Range("E83").Interior.ColorIndex = 4
Else
EndIf
If Range("D81").Value >= "Green" Then
Range("E84").Interior.ColorIndex = 4
Else
EndIf
Application.EnableEvents = True
ActiveSheet.Protect "password"
' this is where I get the 1004 message! Next statement!
ActiveSheet.Range("D80:D84").Locked = False ' unlock the cells
ActiveSheet.Range("F80:F84").Locked = False ' unlock the cells
End Sub
I have a Workbook which I want to update in VB code. It's on a protected sheet, which I unprotect, make the changes, protect again and this all seems to work until I then want to unlock a few cells for my colleagues to have access too.
Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
ActiveSheet.Unprotect "password"
If Range("D80").Value >= "Green" Then
Range("E83").Interior.ColorIndex = 4
Else
EndIf
If Range("D81").Value >= "Green" Then
Range("E84").Interior.ColorIndex = 4
Else
EndIf
Application.EnableEvents = True
ActiveSheet.Protect "password"
' this is where I get the 1004 message! Next statement!
ActiveSheet.Range("D80:D84").Locked = False ' unlock the cells
ActiveSheet.Range("F80:F84").Locked = False ' unlock the cells
End Sub