2015-05-25 37 views
1

我想刪除列A含#REF每一行刪除與#REF每一行使用VBA

我的代碼只能與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 
+0

工作表上是否存在其他可能的錯誤? – Jeeped

回答

0

您可以使用Range.SpecialCells method快速找到Worksheet.UsedRange property內的所有錯誤。

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 
+0

非常感謝!你是偉大的))))它的工作;) – werwq

+0

我只是仍然有一個問題,當沒有錯誤Cellule,它寫我一個VBA錯誤'cellule not found''。我怎樣才能避免這種情況? – werwq

+0

如果遇到錯誤,您可以指定該過程應該簡單地恢復處理。看到我上面的編輯。 – Jeeped