用#REF删除每一行使用VBA

我想删除列A中包含#REF每一行

我的代码只能处理value ,不能用#REF

 Dim varFindThis As Variant Dim rngLookIn As Range Dim f As String varFindThis = Worksheets("Suivi2").Range("B1") Set rngLookIn = Worksheets("Suivi2").Range("A:A") If Not rngLookIn.Find(varFindThis, LookIn:=xlValues) Is Nothing Then f = Worksheets("Suivi2").Range("B1").Value 'Since i didn't got that clear, here above you must create a code to declare "f" as whatever you want Set c = Worksheets("Suivi2").Range("A:A").Find(f) Worksheets("Suivi2").Range(c.Address).EntireRow.Delete End If 

您可以使用Range.SpecialCells方法快速查找Worksheet.UsedRange属性中的所有错误。

 on error resume next with Worksheets("Suivi2").Columns(1) if not .specialcells(xlCellTypeFormulas, xlErrors) is nothing then _ .specialcells(xlCellTypeFormulas, xlErrors).EntireRow.Delete end with on error goto 0