EXCEL VBA重叠错误

时间:2014-09-01 06:58:26

标签: excel-vba vba excel

    Range("A1:C7").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete 
End Sub

这是用于删除空白行的已记录VBA宏的一部分,但它在行Run time error "1004" - "cannot use that command on overlapping selection"中显示错误Selection.EntireRow.Delete

什么似乎是问题?

1 个答案:

答案 0 :(得分:1)

一个简单的循环示例:

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