item not found in “Find” vba

后端 未结 4 659
长发绾君心
长发绾君心 2020-12-17 03:08

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

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 03:58

    Just for posterity, this is how you do it w/out error handling (from: http://www.mrexcel.com/forum/excel-questions/519070-visual-basic-applications-error-handling-when-dealing-cells-find.html).

    Dim rngFound As Range
    
    Set rngFound = Sheets("WhateverSheet").UsedRange.Find(What:="SoughtValue",LookIn:=xlFormulas)
    
    If Not rngFound Is Nothing Then
      'you found the value - do whatever
    Else
      ' you didn't find the value
    End if
    

提交回复
热议问题