MrExcel Publishing
Your One Stop for Excel Tips & Solutions

If checkbox is checked then change color of text??


Posted by Glen on February 09, 2002 10:57 PM

I have some check boxes followed by textboxes...
I plan to have text in the boxes, and when the check box is checked, I would like the text to change colors. I know this should be easy, but I've tried what little knowledge I have in Excel. I suppose this would need a conditional statement?? Please help


Posted by Ivan F Moala on February 09, 2002 11:38 PM

ActiveX control textbox & CheckBox;

Private Sub CheckBox1_Click()
Dim lngC As Long
If CheckBox1.Value Then
lngC = &HFF& 'Red
Else
lngC = &H80000008 'Window text
End If
ActiveSheet.OLEObjects("TextBox1").Object.ForeColor = lngC
End Sub

where textbox1 is the name of the textbox
This code goes in the sheets code area


HTH

Ivan