简体   繁体   中英

EXCEL VBA overlap error

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

This is part of a recorded VBA macro for deleting blank rows but it's showing an error Run time error "1004" - "cannot use that command on overlapping selection" in the line Selection.EntireRow.Delete .

What seems to be the problem?

A simple loop example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM