메인 컨텐츠로 가기

Excel에서 헤더가있는 빈 열을 삭제하는 방법은 무엇입니까?

여러 열을 포함하는 큰 워크 시트가 있지만 일부 열에는 머리글 만 포함되어있는 경우 다음 스크린 샷을 표시하기 위해 머리글 만있는 빈 열을 삭제하려고합니다. Excel에서 빠르고 쉽게 해결할 수 있습니까?

문서 헤더 1이있는 빈 열 삭제

VBA 코드를 사용하여 헤더가있는 빈 열 삭제

Excel 용 Kutools를 사용하여 범위 / 워크 시트 / 통합 문서에서 여러 개의 빈 열 삭제


화살표 블루 오른쪽 거품 VBA 코드를 사용하여 헤더가있는 빈 열 삭제

엑셀에서는 수동으로 하나씩 삭제하는 것 외에는이 작업을 직접 처리하는 방법이 없지만, 여기서는 코드를 소개해 드릴 수 있습니다. 다음과 같이 해주세요.

1. 누르고있어. ALT + F11 키를 누른 다음 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 헤더가있는 빈 열 삭제 :

Sub Macro1()
'updateby Extendoffice
    Dim xEndCol As Long
    Dim I As Long
    Dim xDel As Boolean
    On Error Resume Next
    xEndCol = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    If xEndCol = 0 Then
        MsgBox "There is no data on """ & ActiveSheet.Name & """ .", vbExclamation, "Kutools for Excel"
        Exit Sub
    End If
    Application.ScreenUpdating = False
    For I = xEndCol To 1 Step -1
        If Application.WorksheetFunction.CountA(Columns(I)) <= 1 Then
            Columns(I).Delete
            xDel = True
        End If
    Next
    If xDel Then
        MsgBox "All blank and column(s) with only a header row have now been deleted.", vbInformation, "Kutools for Excel"
    Else
        MsgBox "There are no Columns to delete as each one has more data (rows) than just a header.", vbExclamation, "Kutools for Excel"
    End If
    Application.ScreenUpdating = True
End Sub

3. 그런 다음 F5 키를 눌러이 코드를 실행하면 헤더가있는 빈 열이 삭제 될 것임을 알리는 프롬프트 상자가 나타납니다. 스크린 샷을 참조하십시오.

문서 헤더 2이있는 빈 열 삭제

4. 그런 다음 OK 버튼을 클릭하면 현재 워크 시트의 헤더 만있는 모든 빈 열이 한 번에 삭제됩니다.

주의 사항: 빈 열이 있으면 함께 삭제됩니다.


화살표 블루 오른쪽 거품 Excel 용 Kutools를 사용하여 범위 / 워크 시트 / 통합 문서에서 여러 개의 빈 열 삭제

때로는 빈 열만 삭제하면됩니다. Excel 용 Kutools숨겨진 (표시) 행 및 열 삭제 유틸리티를 사용하면이 작업을 쉽게 완료 할 수 있습니다.

Excel 용 Kutools : 300 개 이상의 편리한 Excel 추가 기능으로 30 일 동안 제한없이 무료로 사용해 볼 수 있습니다.. 

설치 후 Excel 용 Kutools, 다음과 같이하십시오.

1. 삭제해야하는 빈 열을 포함하는 열 범위를 선택합니다.

2. 그런 다음 쿠툴 > . > 숨겨진 (표시) 행 및 열 삭제, 스크린 샷 참조 :

3. 에서 숨겨진 (표시) 행 및 열 삭제 대화 상자에서 필요에 따라 찾는 위치 드롭 다운에서 삭제 범위를 선택할 수 있습니다. 인사말 유형 삭제 섹션을 선택한 다음 빈 열 인사말 자세한 유형 섹션, 스크린 샷 참조 :

문서 헤더 4이있는 빈 열 삭제

4. 그런 다음 Ok 버튼을 누르면 빈 열만 한 번에 삭제됩니다. 스크린 샷보기 :

문서 헤더 5이있는 빈 열 삭제

방문 꿀팁:이 강력한 기능으로 필요에 따라 빈 행, 보이는 열 또는 행, 숨겨진 열 또는 행을 삭제할 수도 있습니다.

지금 Excel 용 무료 다운로드 Kutools를 클릭하십시오!

최고의 사무 생산성 도구

🤖 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 (10)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
All I keep getting is "There are no Columns to delete as each one has more data (rows) than just a header." Yet I know for a fact I have about 700 columns with a header and no data. I have a spreadsheet with over 900 columns and only 200ish have data below the header. Another macro worked but I had to delete the header row. So I know this macro is not working correctly. What's up?
This comment was minimized by the moderator on the site
Hello, Paul
The VBA code works well if there is only one header row in the worksheet, if there are two or more header rows, it will pop out the prompt message you said.
So you need to check out if there are hidden heading rows in your data.
Thank you!
This comment was minimized by the moderator on the site
Hello, I have the same issue, I know by fact that I have a lot of columns that have only headers but the same Error "There are no Columns to delete as each one has more data (rows) than just a header." and I have checked there are no hidden rows in the data.
Can anyone help me ?
This comment was minimized by the moderator on the site
Hi, Simoch
In this case, you can upload your Excel file attachment here, so that we can help to check the problem if you don't mind.
Thank you!
This comment was minimized by the moderator on the site
Dear skyyang no need, It worked perfecty now !! thank you so much for that VBA code !
Rated 5 out of 5
This comment was minimized by the moderator on the site
Amazing! You are correct. There must have been something hidden. Everything is working great now. Thank you so much for the quick reply.
This comment was minimized by the moderator on the site
Can this be saved in one spreadsheet and run on other files?
This comment was minimized by the moderator on the site
Works perfectly. Greatly appreciated
This comment was minimized by the moderator on the site
OMG, this is genius!!! thank you
This comment was minimized by the moderator on the site
Hi, Thanks for the nice code above. Is it free to use?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations