On Error Resume Next
Columns("C").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
On Error GoTo 0
Range("A6").Select
这就是我所拥有的。我工作得很好。
问题是当列 C 没有错误时,它一直显示一条错误消息,说明它无法对错误类型进行微调。
有错误时它工作正常。
有谁知道如何解决这一问题?也许是一个 if 语句?
多谢你们
这似乎有效:
Sub marine()
Dim r As Range
On Error Resume Next
Set r = Range("C:C").Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0
If Not r Is Nothing Then
r.EntireRow.Delete
End If
End Sub
如果它不起作用并且您仍然看到错误消息,则必须启用错误处理。从 VBE 窗口菜单:
工具>选项... >常规> 并确保选中未处理错误时中断。