我在查找用戶ID列表。但是有些用戶不再存在。我試過test
方法,on error go to
方法和if err.number<> 0 then
方法。我仍然收到Run-time error '91': object variable or with block variable not set
。該號碼不存在於列表中。下面是我的代碼,有幾個沒有結果的嘗試項目找不到「查找」vba
On Error GoTo errorLn
If Err.Number <> 0 Then
GoTo errorLn
End If
Cells.Find(What:=uSSO, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
還有什麼其他的選擇?或者我錯誤地放錯了「錯誤」這一行?我試過它之前和之後的「cells.Find ...」
如果我在for循環中,「on error resume next」是否恢復for循環的下一步? – orangehairbandit 2012-08-15 17:08:23
正確 - 它基本上就像一切都好,這是你需要小心使用它的一個原因。有關處理錯誤的不同方法的一個很好的解釋,請查看http://www.cpearson.com/excel/errorhandling.htm。 – RocketDonkey 2012-08-15 17:12:21
非常感謝! – orangehairbandit 2012-08-15 17:15:33