View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Easy newbie question

Dim rng as Range
set rng = Range("A2:A100").Find(mystring, _
Lookin:=xlValues, Lookat:=xlpart)
if not rng is nothing then
msgbox "found in " & rng.Address
End if

--
Regards,
Tom Ogilvy


"KR" wrote in message
...
I have a string in VBA (variable "mystring") and text strings in Sheet1,
column A (A2:A100). I need to identify (in VBA) whether "mystring" is
already in the range of A2:A100, but I will be repeating this operation
thousands of times, so I'm looking for something better than just looping
A2:A100 and checking against each value individually, something more like:

If mystring (is in) Sheet1.range("A2:A100") then....

but I can't find the right keyword- I've looked for "contains",

"includes",
"in", and others.... what is the proper way to write this?

Many thanks,
Keith

--
The enclosed questions or comments are entirely mine and don't represent

the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.