Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Resizing Checkboxes.
Written by Allen Wyatt (last updated August 3, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
When working in VBA, one of the things you can create is known as a "user form." These forms provide you with the ability to essentially create your own dialog boxes. You can add many different types of controls to a user form, if desired. For instance, you can add labels, text boxes, drop-down lists, radio buttons, and many other controls. Some of the controls you can resize; others you cannot. One that you cannot resize is a checkbox. While you can modify the font size used for the label next to the checkbox, you cannot resize the checkbox itself.
If you find the checkboxes in your user forms too small for your taste, you can "work around" them by simulating a checkbox. You do this by actually creating a label instead of a checkbox. Then, change the properties of the label so that it has a transparent background, and that the font being used is Wingdings. You should also make sure that the font is set to a large size, such as 20 or 26 points.
Now, double-click on your label, which should open a code window. The event that you are programming is the Click event for the label, which means it will be executed whenever the label is clicked. Use this as your code:
Private Sub Label1_Click() If Label1.Caption = Chr(254) Then Label1.Caption = Chr(168) Else Label1.Caption = Chr(254) End If End Sub
In the Wingding font, Chr(254) is box with a checkmark, and Chr(168) is a box with no checkmark. When you execute the user form and click on the label, it switches between an empty box and a checked box. You can also add other code to the Click event that performs other tasks, as necessary.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8566) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Resizing Checkboxes.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
When developing macros, you can create subroutines. This is a great way to reuse common code and make your programming ...
Discover MoreCreating macros can help extend what you can do in Excel. If you work with macros, you know that creating macros from ...
Discover MoreYou can, within a macro, save a workbook in several different file formats that are understood by Excel. However, you may ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-06-04 05:45:36
Elle
Why does microsoft make the actual checkboxes so very small then make it so very difficult to change size to enlarge the actual checkbox so it is easier to view? Why the need to need to be knowledgeable in programming before a general user can even make the checkbox bigger? The purpose is to make user's life easier, not harder.........
2024-04-10 22:00:00
Ian
If i have multiple labels that i need to do this i.e. creating muliple checkboxes, how to code it?
2022-08-04 04:43:16
Hans Hallebeek
Great tip, now figure out if I could use two font types in one Lable Caption
That is if the checked checkbox is visible the add the text "Click to uncheck" and v.v.
2022-08-03 16:39:12
Cam Peneff
so i used the checkbox tip - nice... but now the text in a smaller font doesnt sit on the line correctly. Im sure you have some suggestions....
2015-07-14 07:57:05
Murray
Me again. I Googled the issues I was having and mine was by no means an isolated case. Throw in virtual desktops and things can get ugly very fast. I ended up going back to good 'ol form controls rather than ActiveX. Yes, they are pretty basic, but they do the basics reliably. With a few techniques, you can pretty much achieve the same results. I wish the ActiveX controls worked better, because they look a lot better...
2015-07-13 22:41:28
Murray
A couple of things I noticed.
Firstly the code on this page is identical to the other page for Excel 2003. I was looking to use this with a customer with a mixed environment (2003/2010). There is no clear difference indicated in the implementation. Secondly, for no apparent reason after resizing the boxes a little I found that after each click the font got smaller and smaller till it was no longer possible to see the checkbox, let alone click on it. Toggling the autosize property restores the proper size, but then it diminishes back to nothing when out of design mode.
2015-03-25 09:43:32
Roger
I think I found the solution to my problem. http://stackoverflow.com/questions/27411399/microsoft-excel-activex-controls-disabled
2015-03-23 16:12:01
Roger
This works great when I first do it. However, when I save the workbook and re-open it, it no longer functions. Clicking on the label control no longer has any effect, and I can't add another one on the sheet. I've tried several times; Moved the code fromthe sheet to a standard module; Checked the trust settings (Office 2010); Saved the workbook as xlsm, xlsb, and xls; None of them work when re-opened. When I try to change the properties, I get the sheet properties instead.
2015-01-09 16:19:35
Marc
Got it! Thanks for this workaround, it's great!!
2015-01-09 16:13:02
Marc
I have created this code as recommended but the item that appears in the label is the actual symbol that would appear in the bar above when the wingding is normally used, not the box with or without the check mark. So the checked box is actually a lower case b with a tail on the bottom and the unchecked box looks like a colon. Is there a fix for this?
2014-09-04 13:16:51
Kenneth
Can someone please explain this step by step so the average Joe can understand this. Thank you
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments