任何人都可以建议如何使用以下代码处理“未找到单元格”错误。这是一个较大的 sub 的一部分,通常可能不返回任何值,但是按如下方式处理错误(适用于我的许多其他场景)仍然返回“运行时错误'1004':未找到单元格”。我究竟做错了什么?
On Error GoTo Error_Exit_3
Range("Q:Q").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Delete
Error_Exit_3:
最佳答案
我会做什么:
Dim RowsWithFormulas As Long
On Error Resume Next
RowsWithFormulas = Range("Q:Q").SpecialCells(xlCellTypeFormulas, 16).Rows.Count
On Error GoTo 0
If RowsWithFormulas > 0 Then
Range("Q:Q").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Delete
End If
关于excel - 1004 未找到单元格 - 错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55225173/