VBA Excel - 无法在重叠选择上使用该命令

CC2*_*268 3 excel vba

我的代码似乎可以工作,但它突出显示了我的最后一行代码,并显示“运行时错误‘1004’:无法在重叠选择上使用该命令。”

我尝试了在网上找到的一些各种更改,但似乎无法修复该错误。

Sub Delete_EEE()

Dim Wrds As Variant, Gwrds As Variant, i As Long, Fnd As Range, fAdr As String

Gwrds = Array("jan", "m123", "06014", "06015", "06016", "t49", "m39", "cwr", "rnc", "d55", "rer", "rlr", "rwr", "M55", "5962")

Wrds = Array("ohm", "resistor", "semiconductor", "MCKT", "MICKT", "microcircuit", "inductor", "xfmr", "eeprom", "oscillator")

'Application.ScreenUpdating = False

For i = LBound(Gwrds) To UBound(Gwrds)
    Set Fnd = Range("G:G").Find(Gwrds(i), , , xlPart, , , False)
    If Not Fnd Is Nothing Then
        fAdr = Fnd.Address
        Fnd.Value = "#N/A"
        Do
            Set Fnd = Range("G:G").FindNext(Fnd)
            If Fnd Is Nothing Then Exit Do
            If Fnd.Address = fAdr Then Exit Do
            Fnd.Value = "#N/A"
        Loop
    End If
Next i

For i = LBound(Wrds) To UBound(Wrds)
    Set Fnd = Range("E:E").Find(Wrds(i), , , xlPart, , , False)
    If Not Fnd Is Nothing Then
        fAdr = Fnd.Address
        Fnd.Value = "#N/A"
        Do
            Set Fnd = Range("E:E").FindNext(Fnd)
            If Fnd Is Nothing Then Exit Do
            If Fnd.Address = fAdr Then Exit Do
            Fnd.Value = "#N/A"
        Loop
    End If
    Set Fnd = Range("I:I").Find(Wrds(i), , , xlPart, , , False)
    If Not Fnd Is Nothing Then
        fAdr = Fnd.Address
        Fnd.Value = "#N/A"
        Do
            Set Fnd = Range("I:I").FindNext(Fnd)
            If Fnd Is Nothing Then Exit Do
            If Fnd.Address = fAdr Then Exit Do
            Fnd.Value = "#N/A"
        Loop
    End If
Next i

Range("E:I").SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete

'Application.ScreenUpdating = True

End Sub
Run Code Online (Sandbox Code Playgroud)

小智 7

当我尝试删除包含隐藏列的整行时,我遇到了此错误。在尝试 Entirerow.delete 之前,我让程序取消隐藏列,这对我有用。