2014-09-01 3 views
1
Range("A1:C7").Select 
    Selection.SpecialCells(xlCellTypeBlanks).Select 
    Application.CutCopyMode = False 
    Selection.EntireRow.Delete 
End Sub 

이 빈 행을 삭제하기위한 기록 VBA 매크로의 일부이지만 라인 Selection.EntireRow.Delete에서 오류 Run time error "1004" - "cannot use that command on overlapping selection"을 보여주는 것.엑셀 VBA 중복 오류

무엇이 문제입니까?

+1

같은 행에 하나 이상의 열에서 빈 셀이있는 경우 코드는 작동하지 않습니다. 열을 반복해야합니다. – Rory

+0

예 행에 빈 셀이 두 개 있습니다. 루프 코드가있는 세 개의 열 "A", "B", "C"를 고려하여 예제를 제공하십시오. – Cham

답변

1

간단한 루프 예 :

Dim rgCol     As Range 
On Error Resume Next 
For Each rgCol In Range("A1:C7").Columns 
    rgCol.SpecialCells(xlCellTypeBlanks).EntireRow.Delete 
Next rgCol 
+0

고마워요, 로리. 이 코드는 정상적으로 작동합니다. 감사.. – Cham