How to auto-center checkbox in cell in Excel?
While inserting check boxes in cells in Excel, you might notice that it is hard to arrange all checkboxes orderly as the left screenshot shown. Actually, you can move all check boxes to cell center to keep them in order neatly. Method in this article can help you.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
To automatically center all checkboxes in cells in a current worksheet, please do as follows.
1. In the worksheet, you need to auto-center all checkboxes, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, please click Insert > Module. Then copy and paste VBA code into the code window.
VBA code: Automatically center all checkboxes in cells
Sub CenterCheckbox () Dim xRg As Range Dim chkBox As OLEObject Dim chkFBox As CheckBox On Error Resume Next Application.ScreenUpdating = False For Each chkBox In ActiveSheet.OLEObjects If TypeName(chkBox.Object) = "CheckBox" Then Set xRg = chkBox.TopLeftCell chkBox.Width = xRg.Width * 2 / 3 chkBox.Height = xRg.Height chkBox.Left = xRg.Left + (xRg.Width - chkBox.Width) / 2 chkBox.Top = xRg.Top + (xRg.Height - chkBox.Height) / 2 End If Next For Each chkFBox In ActiveSheet.CheckBoxes Set xRg = chkFBox.TopLeftCell chkFBox.Width = xRg.Width * 2 / 3 chkFBox.Height = xRg.Height chkFBox.Left = xRg.Left + (xRg.Width - chkFBox.Width) / 2 chkFBox.Top = xRg.Top + (xRg.Height - chkFBox.Height) / 2 Next Application.ScreenUpdating = True End Sub
3. Press the F5 key. Then all checkboxes are moved into the center of the cells immediately as below screenshot shown.
Note: This VBA code can be applied to both CheckBox (ActiveX Control) and CheckBox (Form Control).
- How to create a drop down list with multiple checkboxes in Excel?
- How to change a specified cell value or color when checkbox is checked in Excel?
- How to highlight cell or row with checkbox in Excel?
- How to make checkbox checked based on cell value in Excel?
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 2 months agoThis worked great for me except it doesn't align it with the text in the next cell which is bottom aligned. Is there a way to align the checkboxes for bottom aligned in order to get them to align with the text in the next cell? Thanks!
- To post as a guest, your comment is unpublished.· 1 years agoYou VDA script is partly working. Because when i applied it, linked cell next to Checkbox get changed and got linked with a cell under it.