I'd prefer to use the .Find
method directly on a range object containing the range of cells to be searched. For original poster's code it might look like:
Set cell = ActiveSheet.Columns("B:B").Find( _
What:=celda, _
After:=ActiveCell _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False _
)
If cell Is Nothing Then
'do something
Else
'do something else
End If
I'd prefer to use more variables (and be sure to declare them) and let a lot of optional arguments use their default values:
Dim rng as Range
Dim cell as Range
Dim search as String
Set rng = ActiveSheet.Columns("B:B")
search = "String to Find"
Set cell = rng.Find(What:=search, LookIn:=xlFormulas, LookAt:=xlWhole, MatchCase:=False)
If cell Is Nothing Then
'do something
Else
'do something else
End If
I kept LookIn:=
, LookAt::=
, and MatchCase:=
to be explicit about what is being matched. The other optional parameters control the order matches are returned in - I'd only specify those if the order is important to my application.