View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John[_19_] John[_19_] is offline
external usenet poster
 
Posts: 87
Default baffling find method problems

In the example below there is a "2" in cell A1 and cell A3. If I define
field as Range("a1:c1") and searchorder as Xlbyrows then it finds the
"2" in cell a1 first. However, if I define Field as Range("A1:C3")the
Find skips cell a1 and finds the "2" in cell a3 first. Then a findnext
will find the 2 in cell a1.

I have discovered that if I define the range one row above what I really
want then it will get the first occurance in the correct cell.

thus: Range("a6:c9" starts searching in cell a7. (Assuming the After: is
a6 which is the default)

If this is true... how do you get it to start a search in cell a1?

Again, if this is just the way it works it means the Find method looks
in upper left cell last unless it's looking in just 1 row. This is
pretty confusing.

I guess my question is, is this the way Find method is supposed to work
or am I doing something wrong?

Thanks

John



Set Field = Range("A1:C1") ... or Range("A1:C3")

Set First = Field.Find(What:="2", LookIn:=xlValues, After:=Cells(1, 1),
lookat:=xlPart, searchorder:=xlByRows, Searchdirection:=xlNext,
MatchCase:=False)

FoundFirst = First.Address