0 votes
in VBA by Beginner (5 points)

How can I change the Interior color from a checkbox?


1 Answer

+1 vote
by Super Expert (3.2k points)
selected by
Best answer

There are 3 different types of CheckBoxes in Excel: UserForm, Form Control, and ActiveX CheckBoxes. This answer will show you how to change the interior color for each of these CheckBox types manually and using VBA.

UserForm CheckBoxes

UserForm CheckBoxes are placed on top of a UserForm you design in the VBA Editor. To change the interior color of UserForm CheckBox, you adjust the BackColor property. You can do this by hand or you can do it with VBA, like this:

Me.CheckBox1.BackColor = RGB(255, 0, 0)

Change "Me" to the name of the UserForm if your code isn't placed in the UserForm whose checkbox you're wanting to change.

Form Control CheckBoxes

Form Control CheckBoxes are located under Insert > Form Controls on your Developer Tab in Excel and are placed within a spreadsheet itself.

Form Control CheckBox

You can change the interior color of a Form Control CheckBox manually by right-clicking it, selecting "Format Control" and selecting a Fill Color. 

There are 2 common ways to change the interior fill color of a Form Control CheckBox using VBA. This macro presents both, with the second method commented out:

Sub FormControl_CheckBox_Fill()
ActiveSheet.CheckBoxes("Check Box 1").Interior.Color = RGB(255, 0, 0)
'ActiveSheet.Shapes("Check Box 1").OLEFormat.Object.Interior.Color = RGB(255, 0, 0) 'Alternate Method
End Sub

ActiveX CheckBoxes

ActiveX CheckBoxes are the 3rd type of CheckBox you can make in Excel. Like the Form Control CheckBoxes, the ActiveX CheckBoxes also go on your spreadsheet. They're located under Insert > ActiveX Controls on your Developer Tab. 

ActiveX CheckBox

You can adjust the interior color manually by accessing the BackColor property of the control, just like with UserForm Controls. To do this, make sure "Design Mode" is clicked on your Developer Tab. 

Design Mode on Developer Tab

Once it's clicked, right-click your checkbox and click Properties. This will bring up a new screen where you can adjust the BackColor property:

BackColor Property of ActiveX CheckBox

You can change the BackColor property using VBA with one of these 2 methods:

Sub ActiveX_CheckBox_Fill()
ActiveSheet.CheckBox1.BackColor = RGB(255, 0, 0)
' ActiveSheet.OLEObjects("CheckBox1").Object.BackColor = RGB(255, 0, 0) 'Alternate Method
End Sub

Notice the Name of the CheckBox matches the Name Property of the ActiveX CheckBox.

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.


For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.