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.
With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. 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.
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.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8566) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Resizing Checkboxes.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!