首页 > 解决方案 > VBA CODE RUNTIME ERROR 1004 表示对象定义错误

问题描述

我正在使用 Excel 2007。

我试图在 VBA 中的代码块下方运行,但出现运行时错误 1004,对象定义错误。

代码:

Sub Delete()

If Range("A1") = "" Then
With Sheets("Filter")
Dim ARS As Long
    For ARS = .Range("B" & Rows.Count).End(x1up).Row To 5 Step -1
        If Right(.Cells(ARS, "B").Value, 3) = "ARS" Then .Rows(ARS).ClearContents
        If Right(.Cells(ARS, "B").Value, 3) = "Ars" Then .Rows(ARS).ClearContents
        If Right(.Cells(ARS, "B").Value, 3) = "ars" Then .Rows(ARS).ClearContents
    Next
End With
End If

end Sub

我的目标是在 ARS 为空的情况下从表中删除 ARS。

对于所有团队 ARS、FUL、LIV 等,我在 Sub Delete 例程中有许多类似的块

有关我的数据,请参阅附件图像。

提前致谢!!

在此处输入图像描述

标签: excelvba

解决方案


推荐阅读