Range.Find skips the first cell ??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It seems that a straight forward Range.Find() call implicitly starts
searching AFTER the first cell in the range, AS IF called as

f = r.Find(after:=r.cells(1,1),...)

This work-around is effective:

f = r.find(after:=r.cells(r.Rows.Count, r.Columns.Count),...)

but it's (obviously) fugly. Am I missing something?
 
What do you want it to do instead?

The example in Help has useful code.

Tim.
 
I like to start after the last cell in the range and look for the next cell...

Something like:

Dim myRng as range
Dim FoundCell as range

set myrng = worksheets("Sheet1").range("a1:z99")

With myRng
Set FoundCell = .Cells.Find(what:="what to look for", _
after:=.Cells(.Cells.Count), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False)
End With
 
I want find to behave according to MY sensibilities <smile>, to wit: that
when no "After" parameter is provided, it returns the FIRST cell to match the
criteria, not the first match after the first cell.

Judging from other responses and other sources, it seems I will just have to
live with this semantic despite how much pain it causes... <sigh>
 
Yeah, your solution is the same as mine - except yours is noticibly cleaner.
Despite being disgusted by this behavior I'm sure I can learn to make due
<smirk>.

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top