Reputation: 443
I have this code written under a command button, the sheet is protected. The command button acts as a reset button and deletes data from many cells and changes font property. Here is the code: The ranges that I am changing using this button are already added to exception
Range("C10:c18") = ""
Range("C20:c24") = ""
Range("c5:c6") = "_"
Range("c11:c12") = "Optional"
With Range("c11:c12")
With .Font
.Italic = True '"Line 1"
.ColorIndex = 48 '"Line 2"
End With
End With
It throws the VBA Error: Unable to to set the italic property of the font class for line 1 and
Application defined or object defined error for line 2
Upvotes: 1
Views: 1585
Reputation: 34045
You must allow formatting cells when protecting the sheet, or protect the sheet on Workbook_Open using the UserInterfaceOnly:=True argument, so that your code can work even on protected sheets (for most things, anyway).
Upvotes: 6