M
Matt
I have code that changes the cell shading in a worksheet, however, when I protect the worksheet, I get an error in any code that changes the shading in cells. I'm not sure if I need to add some code so that it will allow the changes when protected or if I need to add code to unprotect it then place protection on it again. Any help would be greatly appreciated. Here is an example of the code that is causing problems. Thanks. Mat
Private Sub Workbook_BeforePrint(Cancel As Boolean
If ActiveSheet.Name = "TIME AND LEAVE" The
Cancel = Tru
Application.EnableEvents = Fals
Application.ScreenUpdating = Fals
With ActiveShee
.Range("A140").Interior.ColorIndex = xlNon
.PrintOu
.Range("A5:B5,C69,O10:O11,M10:M11,K10:K11,I10:I11,G10:G11,E10:E11,A10:C11,C1212,O16,M16,K16,I16,G16,E16,A16:C16,A1733,O3440,A34:B40").Interior.ColorIndex = 2
End Wit
Application.EnableEvents = Tru
Application.ScreenUpdating = Tru
End I
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean
If ActiveSheet.Name = "TIME AND LEAVE" The
Cancel = Tru
Application.EnableEvents = Fals
Application.ScreenUpdating = Fals
With ActiveShee
.Range("A140").Interior.ColorIndex = xlNon
.PrintOu
.Range("A5:B5,C69,O10:O11,M10:M11,K10:K11,I10:I11,G10:G11,E10:E11,A10:C11,C1212,O16,M16,K16,I16,G16,E16,A16:C16,A1733,O3440,A34:B40").Interior.ColorIndex = 2
End Wit
Application.EnableEvents = Tru
Application.ScreenUpdating = Tru
End I
End Sub