VBA & Macro Problems

Resize Excel Form Control Check Boxes with VBA

Phi Hung VoPhi Hung Vo Nov 20, 2026 869 views

Question details

The user wants to fit Excel Form Control check boxes to their captions and adjust their widths and alignment together.

Resize Excel Form Control Check Boxes with VBA
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.
Before you start

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).

Solution 1Recommended

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.

1
Check the longest caption

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.

2
Add the selection macro

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

3
Run the macro

Return to the worksheet, open Developer > Macros, select SelectFormCheckBoxes, and click Run. The matching check boxes on the active sheet will be selected.

4
Set the width and alignment

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.

Select Form Control check boxes with VBA and set a common width
Check the result: A common width accommodates the longest caption but may leave extra space beside shorter captions. Alignment commands can move the selected controls.
Free Microsoft Office alternative

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.

Open and edit Microsoft Excel XLS and XLSX filesWork with spreadsheet layouts in a familiar interfaceUse a free, lightweight suite for everyday spreadsheet tasksMove existing Office documents into WPS without starting from scratch
microsoft office alternative - wps office

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.