edit - file test.xlsm attached
I'm trying to change label text colors dynamically in a user form based on the value of a checkbox.
Objects:
checkbox: chkTest
label: lblTest
textbox: txtTest
I set label's forecolor in the control's property to red (H000000FF) then run the following code:
Private Sub chkTest_Change()
If chkTest.Value = True Then
lblTest.ForeColor = H0000FF00 'should change text to green if true
txtTest.Value = "On - Green"
ElseIf chkTest.Value = False Then
lblTest.ForeColor = H00FF0000 'should change text to blue if false
txtTest.Value = "Off - Blue"
End If
End Sub
On initialization of the form, the label's text is properly red.
But on chkbox click, the text turns black once and never changes again. The txtbox updates its value properly.
What am I doing wrong?
What I want to do is have a large section of one of my userforms to activate and change color if a particular checkbox is true. If False, then the controls are disabled and are greyed out.
Thanks!
Bookmarks