메인 컨텐츠로 가기

열에 빈 셀이 있으면 행을 자동으로 숨기는 방법은 무엇입니까?

열에 빈 셀을 채우는 데이터 범위가 있고 이제 해당 열에 빈 셀이 포함 된 행을 자동으로 숨기려고합니다. Excel에서이 작업을 빠르고 쉽게 해결할 수있는 좋은 방법이 있습니까?

VBA 코드가있는 열의 빈 셀인 경우 행 자동 숨기기


화살표 블루 오른쪽 거품 VBA 코드가있는 열의 빈 셀인 경우 행 자동 숨기기

다음 코드는 특정 열의 셀이 한 번에 비어있는 경우 모든 행을 숨기는 데 도움이 될 수 있으며 해당 열의 셀 내용을 삭제하면 행도 자동으로 숨겨집니다. 다음과 같이하십시오 :

1. 열에 빈 셀이있는 경우 행을 자동으로 숨기려는 시트 탭을 마우스 오른쪽 버튼으로 클릭 한 다음 코드보기 컨텍스트 메뉴에서 튀어 나온 응용 프로그램 용 Microsoft Visual Basic 창에서 다음 코드를 복사하여 빈 칸에 붙여 넣으십시오. 모듈:

VBA 코드 : 열에 빈 셀이있는 경우 행 자동 숨기기 :

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
    Dim xRg As Range
    Application.ScreenUpdating = False
        For Each xRg In Range("A1:A20")
            If xRg.Value = "" Then
                xRg.EntireRow.Hidden = True
        
            Else
                xRg.EntireRow.Hidden = False
            End If
        Next xRg
    Application.ScreenUpdating = True
End Sub

문서 자동 숨기기 행 1

주의 사항: 위 코드에서 A1 : A20 자동으로 숨기려는 빈 셀이 포함 된 데이터 목록입니다.

2. 그런 다음 워크 시트로 돌아가서 셀을 두 번 클릭하고 엔터 버튼 키를 누르면 A 열의 빈 셀이 포함 된 행이 한 번에 숨겨지며 A 열의 지정된 셀에서 셀 내용을 지우면 행이 자동으로 숨겨집니다.

문서 자동 숨기기 행 2

 

최고의 사무 생산성 도구

🤖 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 (35)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I already copied the code, but nothing happened in my worksheet, Do I need to change anything with the code?
Thank you.
This comment was minimized by the moderator on the site
I already copied the code, but nothing happened in my worksheet, Do I need to change anything with the code?
Thank you.
This comment was minimized by the moderator on the site
I'm trying to find a way hide blank rows in sheet2 from A2:A20, if Sheet!A5=Yes. any suggestion?
This comment was minimized by the moderator on the site
Hi, i'm having issues with the "automation" of the macro. I'm searching for a way for the code to work as an automated process without the needs of "manually" running the macro. i've been using my own variant of your code due to me finding issues to use your code. This is my variant:

Sub HideRows()
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("A3:A800")
If (xRg.Value = "") Then
xRg.EntireRow.Hidden = True
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
Application.ScreenUpdating = True
End Sub

I'm trying to create a spreadsheet which requires everchanging values, therefore would require a genuine "automated" procress. I'm relatively new to VBA and if your code actually already meets my requirements would you mind helping/teach me to apply it in VBA? Thanks.
This comment was minimized by the moderator on the site
Hello, Vian
In fact, the code in our article can be run automatically.
You must copy and paste the code into the code module of current worksheet, then return to the worksheet, double-click any cell, and press the Enter key, the row containing the blank cell will be is directly hidden.

Please follow the method in this article step by step, hope it can help you!
Thank you!
This comment was minimized by the moderator on the site
apakah ada rumus lain?, saya berharap baris kosong itu akan terhapus saat mencetak file menjadi PDF tapi tampilan di excelnya tetap
This comment was minimized by the moderator on the site
Hello, Nurjanah
To solve your problem, first, you should hide the blank rows, and then print the data, after printing the data, you need unhide the blank rows again. Please do as this:
1. Apply this formula: =COUNTA(A2:E2) beside your data, see screenshot:
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-hide-blanks-1.png
2. Then, filter the new helper Blank column, hide all 0 value rows, see screenshot:
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-hide-blanks-2.png
3. And then, you should hide the new Blank column, and print the data, after printing the worksheet, please cancel the filter to unhide the blank rows as you need.
Please try, hope it can help you!
This comment was minimized by the moderator on the site
When executing the code in office 2013/2019/2021 it works but takes too much time to complete (only 95 rows to hide).
How can you speed this?
Thanks!
This comment was minimized by the moderator on the site
Hi, Asaf,
The code works well in my Excel file, could you upload your attachment worbook here if you don't mind? So that we can help to check the problem.

Thank you!
This comment was minimized by the moderator on the site
How to hide row which contain checkbox?
This comment was minimized by the moderator on the site
Hello, Sweta

To hide rows with checkbox, the below article may do you a favor:
How To Hide Checkbox When Row Is Hidden In Excel?

Please try, if you still have any other question, please comment here.
This comment was minimized by the moderator on the site
If the value in column E is blank or 0 i would like the row to auto hide. If the value in E changes to something other than blank or 0 I would like it to show. Report is 1500 rows
This comment was minimized by the moderator on the site
Hello, Cathy,
To hide the rows automatically based on blank cells or 0 values, please use the below vba code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
    Dim xRg As Range
    Application.ScreenUpdating = False
        For Each xRg In Range("E1:E1500")
            If (xRg.Value = "") Or (xRg.Value = "0") Then
                xRg.EntireRow.Hidden = True
            Else
                xRg.EntireRow.Hidden = False
            End If
        Next xRg
    Application.ScreenUpdating = True
End Sub


Please try, hope it can help you!
This comment was minimized by the moderator on the site
I would like to auto hide rows if column E is blank or 0
This comment was minimized by the moderator on the site
This is working great for me, It hides the rows and opens them when my values change based on formulas.  The question I have is my sheet is 104 rows long.  It churns for a bit each time I click a cell.  Any way to speed up the transition when it is activated?  Or is it my computer?Thanks!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations