Hi All,
I have some code to change the font size of a range of merged cells based on the length of text within the cells. The code works fine when the sheet is unprotected, however when I protect it the code fails with the message "Run-time error 1004 - Unable to set the Size property of the Font class".
The code is:
If Len(Range("A26")) > 1000 Then
Range("A26").Font.Size = 6
ElseIf Len(Range("A26")) > 500 And Len(Range("A26")) < 1000 Then
Range("A26").Font.Size = 7
Else:
Range("A26").Font.Size = 8
End If
I can't figure out what is the problem. Can anyone chime in here? Thanks.
I have some code to change the font size of a range of merged cells based on the length of text within the cells. The code works fine when the sheet is unprotected, however when I protect it the code fails with the message "Run-time error 1004 - Unable to set the Size property of the Font class".
The code is:
If Len(Range("A26")) > 1000 Then
Range("A26").Font.Size = 6
ElseIf Len(Range("A26")) > 500 And Len(Range("A26")) < 1000 Then
Range("A26").Font.Size = 7
Else:
Range("A26").Font.Size = 8
End If
I can't figure out what is the problem. Can anyone chime in here? Thanks.