VBA to change Form Control Checkbox background color when checked

FiservEFTSalesOps

New Member
Joined
Dec 7, 2009
Messages
31
I have an Excel 2010 workbook with many worksheets using hundreds of Form Control (not ActiveX) checkboxes. I need a bit of VBA to change Checkbox background color of each checkbox whenever the user checks the box. I assume this needs to be a click event? I don't even know the Checkbox property name I need to change :(
I'm learning VBA as quick as I can, but need some assistance.

Thank you all.
 
Apart from the check box background and font “fore” colour changes is it possible to change the inside colour of the check box itself? The inside of the box that has the check mark symbol which is normally white? Also can the check mark symbol be changed or removed altogether?</SPAN>

That is when the check box is in the disabled state instead of having a white colour it has, lets say a patterned green colour, and when the check box is in the enabled state the patterned green turns to green without the check mark. Sort of to give an ON – OFF effect.</SPAN>
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Please explain what the “x10n” refers to? Is it the check mark inside the check box?</SPAN>
What is the difference between “= msoTrue” and “= True”?</SPAN>

Form's check boxes do not take True or False their values. The value of a Form's checkbox (actually the Shape's ControlFormat's Value) is either of the xlConstants, xlOn (1) or xlOff(-4146).
 
Upvote 0
Apart from the check box background and font “fore” colour changes is it possible to change the inside colour of the check box itself? The inside of the box that has the check mark symbol which is normally white? Also can the check mark symbol be changed or removed altogether?</SPAN>

That is when the check box is in the disabled state instead of having a white colour it has, lets say a patterned green colour, and when the check box is in the enabled state the patterned green turns to green without the check mark. Sort of to give an ON – OFF effect.</SPAN>


I have moved this question to a new post, link below, as yesterday I posted here by mistake.</SPAN>

http://www.mrexcel.com/forum/excel-questions/880028-forms-check-box-question-%96-please-help.html#post4263972</SPAN>
 
Upvote 0
Form's check boxes do not take True or False their values. The value of a Form's checkbox (actually the Shape's ControlFormat's Value) is either of the xlConstants, xlOn (1) or xlOff(-4146).


Thank you for explaining and sorry for my lack of knowledge on VBA. </SPAN>

Maybe you would care to assist to a check box question I posted here.</SPAN>

http://www.mrexcel.com/forum/excel-questions/880028-forms-check-box-question-%96-please-help.html#post4263972</SPAN>
 
Last edited:
Upvote 0
AFAIK, the color of the checking region is always white.


Pity! I thought that it might have been possible to address the checking region with a macro to change the white colour, but it seems that I was wrong. Thanks anyway for your kind reply.

</SPAN>
 
Upvote 0
If you assign a Forms Control Checkbox to this macro, the background color of the checkbox will change between Red and Green, depending on whether the user check or un-checks the box.
Note that several different checkboxes can be assigned to this macro (or if they call separate macros, those can call this) and it will work.

Code:
Sub CheckBox1_Click()
    With ActiveSheet.Shapes(Application.Caller)
        If .ControlFormat.Value = xlOn Then
            With .Fill
                .Visible = msoTrue
                .ForeColor.RGB = RGB(255, 0, 0)
            End With
        Else
            With .Fill
                .Visible = msoTrue
                .ForeColor.RGB = RGB(0, 255, 0)
            End With
        End If
    End With
End Sub
Exactly what I was looking for, can now use select any colour I need - fantastic, thank you,

Boon
 
Upvote 0
The proper Shapes("Check Box 1").ControlFormat.Value of a Forms Check box is xlOn (XL not X(one) On) or xlOff, not True or False.
 
Upvote 0

Forum statistics

Threads
1,223,152
Messages
6,170,389
Members
452,323
Latest member
GoJones

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top