View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default what is the best way to find a value in a sheet in VBA?

You will get an error if the value is not found. Best to do it as Rowan
illustrated.

--
Regards,
Tom Ogilvy


"AG" wrote in message
...
Got it!
Sub test()
With Range("A1:A10").find("xyz", LookIn:=xlValues).Select
End With
End Sub

"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?