Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.UnProtect
Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
Else
Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
End If
ActiveSheet.Protect
End Sub
Gord Dibben MS Excel MVP
>Hi,
>My sheet is protected and the cells are protected.
[quoted text clipped - 26 lines]
>>> white!!)
>>> Can anyone help in writing the code for me?
Khalil Handal - 19 Jun 2007 16:51 GMT
Hi,
When I clicked the box the first time it worked fine.
Then I clicked it again (a second time) and had the following error message:
Unable to set the color property of the font class
any ideas!!!!
> Private Sub CheckBox1_Click()
> If CheckBox1.Value = True Then
[quoted text clipped - 40 lines]
>>>> white!!)
>>>> Can anyone help in writing the code for me?
Dave Peterson - 19 Jun 2007 18:29 GMT
Moving the .unprotect line helped:
Option Explicit
Private Sub CheckBox1_Click()
Me.Unprotect
If CheckBox1.Value = True Then
Me.Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
Else
Me.Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
End If
Me.Protect
End Sub
The me keyword refers to the worksheet that owns the code.
> Hi,
> When I clicked the box the first time it worked fine.
[quoted text clipped - 46 lines]
> >>>> white!!)
> >>>> Can anyone help in writing the code for me?

Signature
Dave Peterson
Khalil Handal - 19 Jun 2007 18:55 GMT
Thanks a lot to all of you.
It worked just fine
> Moving the .unprotect line helped:
>
[quoted text clipped - 70 lines]
>> >>>> white!!)
>> >>>> Can anyone help in writing the code for me?
Rick Rothstein (MVP - VB) - 19 Jun 2007 17:30 GMT
Even more descriptive (in my opinion) are these (which use two of the many,
many predefined constants in VBA)...
> Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
Range("C34:E34").Font.Color = vbWhite
> Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
Range("C34:E34").Font.Color = vbBlack
Rick
Khalil Handal - 19 Jun 2007 19:00 GMT
Yours also worked well; it gave the same result.
thanks
> Even more descriptive (in my opinion) are these (which use two of the
> many, many predefined constants in VBA)...
[quoted text clipped - 8 lines]
>
> Rick