在“查找”中找不到的项目VBA [英] item not found in "Find" vba
问题描述
我正在从列表中查找用户ID#。但是有些用户不再存在。我尝试了测试
方法,错误的转到
方法,而$ code> 。数<> 0然后方法。我仍然收到运行时错误'91':对象变量或块变量未设置
。列表中不存在该号码。以下是我的代码,几次无效的尝试
I'm looking for user ID #s from a list. However some users no longer exist. I've tried the test
method, the on error go to
method, and if err.number<> 0 then
method. I still receive the Run-time error '91': object variable or with block variable not set
. The number does not exist on the the list. Below is my code with a couple of fruitless attempts
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 ...之前和之后尝试过。
What other options are there? Or am I misplacing the lines of "error"? I have tried it before and after the "cells.Find..."
推荐答案
我相信你需要重组只是一点点 b $ b
I believe you'll need to restructure it just a little bit. It is not the best practice to handle errors with On Error Resume Next
, but you could try this:
On Error Resume Next
Cells.Find(What:=uSSO, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
If Err.Number <> 0 Then
'''Do your error stuff'''
GoTo errorLn
Else
Err.Clear
End If
这是否适合您的情况?
这篇关于在“查找”中找不到的项目VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!