ⓒ 2025 AI교육연구회 withseok. All rights reserved. (위드석)
[블로그 글 내용 상업적 이용금지] 위드석홈 | 위드석개발 | AI교육연구회

Option Explicit
Sub 빈행삭제()

'방법1)
    
    Dim rng As Range
    Dim rBL As Range
    
    Set rng = Range("a1", Cells(Rows.Count, "a").End(xlUp))
                'a열의 입력된 맨아래 자료까지 범위 선택
        
    For Each rBL In rng.SpecialCells(xlCellTypeBlanks).Areas
                    '빈셀은 각각 떨어져 있는 다중영역이므로
                    'Areas로 받는다.
        If rBL.Count > 0 Then
            rBL.Resize(rBL.Count, 1).EntireRow.Delete
                    'Resize로 행전체를 선택하여 삭제한다.
        End If
    Next

End Sub

 

두번째)  행의 일부만 삭제하여 뒤쪽 데이터 유지

 

 

Option Explicit
Sub 빈행삭제()

'방법1)
    
    Dim rng As Range
    Dim rBL As Range
    
    Set rng = Range("a1", Cells(Rows.Count, "a").End(xlUp))
                'a열의 맨아래 자료까지 범위 선택
        
    For Each rBL In rng.SpecialCells(xlCellTypeBlanks).Areas
                    '빈셀은 각각 떨어져 있는 다중영역이므로
                    'Areas로 받는다.
        If rBL.Count > 0 Then
            'rBL.Resize(rBL.Count, 1).EntireRow.Delete
                    'Resize로 행전체를 선택하여 삭제한다.
            rBL.Resize(rBL.Count, 5).Delete
                    '각행의 5칸만 삭제한다.
        End If
    Next

End Sub

320x100

+ Recent posts