메인 컨텐츠로 가기

Excel에서 셀의 확인란을 자동 중앙에 배치하는 방법은 무엇입니까?

Excel의 셀에 확인란을 삽입 할 때 왼쪽 스크린 샷과 같이 모든 확인란을 순서대로 정렬하기가 어렵다는 것을 알 수 있습니다. 실제로 모든 확인란을 셀 중앙으로 이동하여 깔끔하게 유지할 수 있습니다. 이 기사의 방법이 도움이 될 수 있습니다.

VBA 코드가있는 셀의 자동 가운데 확인란


VBA 코드가있는 셀의 자동 가운데 확인란

현재 워크 시트의 셀에있는 모든 확인란을 자동으로 가운데에 맞추려면 다음과 같이하십시오.

1. 워크 시트에서 모든 확인란을 자동 중앙에 배치해야합니다. 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭하십시오 끼워 넣다 > 모듈. 그런 다음 VBA 코드를 코드 창에 복사하여 붙여 넣습니다.

VBA 코드 : 자동으로 모든 확인란을 셀 중앙에 배치

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. 누르세요 F5 키. 그런 다음 모든 확인란이 아래 스크린 샷과 같이 즉시 셀 중앙으로 이동합니다.

주의 사항:이 VBA 코드는 CheckBox (ActiveX Control)와 CheckBox (Form Control) 모두에 적용 할 수 있습니다.

팁 : 선택한 범위에 여러 개의 확인란을 일괄 적으로 삽입하려면 일괄 삽입 확인란 유틸리티 pf Excel 용 Kutools. 또는 여러 옵션 버튼을 일괄 삽입 일괄 삽입 옵션 버튼 유용. 또한 모든 확인란을 한 번에 삭제할 수 있습니다. 일괄 삭제 확인란 아래 스크린 샷과 같이 유틸리티. 당신은 갈 수 있습니다 30일 이내에 제한 없이 소프트웨어를 무료로 다운로드하세요..


관련 기사 :

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The VBA does not work at all for me. When I press F5, it appears that the module runs, but the checkboxes did not move.
This comment was minimized by the moderator on the site
After some more experimenting, I figured out that the VBA does work for manually inserted checkboxes, but if I use Kutools batch insert, it does not. How do I center all the checkboxes inserted with Kutools?
This comment was minimized by the moderator on the site
Hi quadma,
The code also works for the checkboxes inserted by Kutools. Which Excel version are you using?
This comment was minimized by the moderator on the site
I'm using office 360. I think the issue that I'm having is that when I use the Kutools batch insert, the size of the the checkbox object is as wide as the column that it's inserted into (i.e. the checkbox object width is greater than it's height), with the visible checkbox itself on being left justified within the object. If I select all the checkbox objects and then resize them so that the height and length are equal, and then run the VBA, it does then center the checkboxes within the column.





This seems like an unnecessary step, given that checkboxes are square, why is Kultools not making the checkbox objects square?
This comment was minimized by the moderator on the site
Hi quadma,
The check boxes inserted by Kutools are the same as the Check Box (Form Control) which inserted by Excel.
I don't really understand you said "making the checkbox object square". Normally a check box include the box field and the value field. Kutools keeps the check boxes' value empty if the selected cells are blank. And if there are values in selected cells, the cell value will be taken as the check box value.
This comment was minimized by the moderator on the site
I've uploaded a picture to show what I mean. Hopefully that helps.
This comment was minimized by the moderator on the site
Hi quadma, I got your point. We will think about it and thank you for your patience.
This comment was minimized by the moderator on the site
This 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!
This comment was minimized by the moderator on the site
You 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.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations