Find (but not find)

  • Thread starter Thread starter Gordon
  • Start date Start date
G

Gordon

My program takes a name from sheet3 goes to sheet1 to Find the name.
If it cannot find name, how do you do an If/End to Exit Do while or
find out if name has been founf? I have "On Error Resume Next" in
program.

Thanks again for all your help
Gordon
 
Gordon said:
My program takes a name from sheet3 goes to sheet1 to Find the name.
If it cannot find name, how do you do an If/End to Exit Do while or
find out if name has been founf? I have "On Error Resume Next" in
program.

Somewhat ambiguous. If you search for the value of Sheet3!X99 in the used
range in Sheet1, maybe adapt the following.


Sub foo()
Dim fc As Range, v As Variant

On Error Resume Next

v = Worksheets("Sheet3").Range("X99").Value
Set fc = Worksheets("Sheet1").UsedRange.Find(What:=v, LookIn:=xlValues)
MsgBox Title:="Finding '" & CStr(v) & "'", _
Prompt:=IIf(fc Is Nothing, "not found", fc.Address(0, 0))

End Sub
 
On Error Resume Next
Set Found = Nothing
Set Found = Cells.Find(whateveryouarefinding)
If Not Found Is Nothing then
'successful
Else
'unsuccessful
End If
Bob Umlas
Excel MVP
 
Back
Top