what is the best way to find a value in a sheet in VBA?
Thanks to both Rowan & Tom for the additional insight.
"Rowan Drummond" wrote:
Try something like:
Sub findit()
Dim fndRng As Range
With Range("A1:A10")
Set fndRng = .Find("abc", LookIn:=xlValues)
End With
If Not fndRng Is Nothing Then
MsgBox "Found in cell: " & fndRng.Address
Else
MsgBox "Not Found"
End If
End Sub
Hope this helps
Rowan
AG wrote:
Please help with the coding for .Find
Example, within a range A1:A10 I would have various values, apples, cans,
abc, toys, etc.
When I write Range("A1:A10").find("abc", LookIn:=xlValues) I get a compile
error of expected =
What am I missing?
"Tom Ogilvy" wrote:
It is the most general way if you don't want to loop.
You can also use the built in lookup, vlookup, match type functions.
--
Regards,
Tom Ogilvy
"serdar" wrote in message
...
.Find(x, LookIn:=xlValues)
Is this the only way?
|