How do I change the forecolor of a CheckBox when True

C

Chip Pearson

Try code like the following:


Private Sub CheckBox1_Click()
With Me.CheckBox1
If .Value <> 0 Then
' checked
.ForeColor = RGB(255, 0, 0) ' Red
Else
' unchecked
.ForeColor = RGB(0, 0, 255) ' Blue
End If
End With
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

PJ Murph

How do I adapt your code into this?
'Public WithEvents CBXGroup As MSForms.CheckBox
Private Sub CBXGroup_Change()'
WhichOne = Mid(CBXGroup.Name, Len("cbxFee") + 1)
With CBXGroup.Parent.OLEObjects("cbxFee" & WhichOne)
.PrintObject = CBXGroup.Value
End With
 
D

Dave Peterson

With cbxgroup.parent.oleobjects("cbxfee" & whichone)
.printobject = cbxgroup.value
with .object
If .Value = True Then
.ForeColor = RGB(255, 0, 0) ' Red
Else
.ForeColor = RGB(0, 0, 255)
End If
end with
End With

(Untested, uncompiled. Watch for typos.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top