Resize Excel Form Control Check Boxes with VBA
Question details
The user wants to fit Excel Form Control check boxes to their captions and adjust their widths and alignment together.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains multiple Form Control check boxes with captions of different lengths.
- Observed behavior
- Form Control check boxes do not expose an AutoSize property, so their widths cannot be fitted to captions using that property.
Open the workbook in a desktop version of Excel that supports VBA, and make the worksheet containing the check boxes active. If you want to keep the macro, save the workbook as an Excel Macro-Enabled Workbook (.xlsm).
Select Form Control check boxes with VBA and set a common width
Use this method to select the active worksheet's Form Control check boxes and format them together.
This procedure selects Form Control check boxes, not ActiveX controls. It does not measure captions or automatically calculate the required width.
On the worksheet, find the caption that needs the most space. Resize its check box manually until the full caption is visible, then note the width shown under Shape Format > Size.
Open Developer > Visual Basic, choose Insert > Module, and paste this code: Sub SelectFormCheckBoxes() Dim shp As Shape Dim names() As Variant Dim n As Long For Each shp In ActiveSheet.Shapes If shp.Type = msoFormControl Then If shp.FormControlType = xlCheckBox Then n = n + 1 ReDim Preserve names(1 To n) names(n) = shp.Name End If End If Next shp If n = 0 Then MsgBox "No Form Control check boxes found on the active sheet." Exit Sub End If ActiveSheet.Shapes.Range(names).Select End Sub
Return to the worksheet, open Developer > Macros, select SelectFormCheckBoxes, and click Run. The matching check boxes on the active sheet will be selected.
With the check boxes selected, open Shape Format or Drawing Tools > Format and enter the noted width in the Size group's Width box. If needed, use Align to position the selected controls together.

Edit Excel spreadsheets with WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing spreadsheets. Its Excel-format support helps you move existing files into WPS, although it does not fix Excel VBA behavior and macro compatibility can vary.

Frequently Asked Questions
Can Excel automatically fit a Form Control check box to its caption?
Form Control check boxes do not provide the AutoSize property. You can manually find a suitable width for the longest caption and apply that width to the selected controls.
Does the macro select ActiveX check boxes too?
No. The macro checks for Form Controls with the check box type. ActiveX controls require a different selection method.
How do I keep the macro in my workbook?
Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). A standard .xlsx file cannot store VBA macros.
Why did the macro find no check boxes?
Check that the intended worksheet is active and that its controls are Form Control check boxes rather than ActiveX controls. Then run the macro again from Developer > Macros.




