目前,我正在使用以下代码来检查某个单元格的A列中是否有#N/A值,如果找到,我将删除该行。迭代范围内的单元格
With Sheets(Sheet)
For LRow = 45 To 29 Step -1
With .Cells(LRow, "A")
If (CVErr(.Value) = CVErr(xlErrNA)) Then .EntireRow.Delete
End With
Next LRow
End With
我需要扩展这个让我检查所有列1到10,而不是仅仅A.我想这轻微的修改(嵌套另一个循环),但它不工作。有什么建议么?
With Sheets(Sheet)
For LRow = 45 To 29 Step -1
For LCol = 10 To 1 Step -1
With .Cells(LRow, LCol)
If (CVErr(.Value) = CVErr(xlErrNA)) Then .EntireRow.Delete
End With
Next LCol
Next LRow
End With
我收到一个'对象不支持属性或方法在设置选择线 – xbonez 2011-02-28 18:02:36
您需要先选择表 - 我已添加在 – 2011-02-28 18:04:53
添加代码以选择工作表。同样的错误。 – xbonez 2011-02-28 18:08:30