Findnext problem

  • Thread starter Thread starter luc.langlois
  • Start date Start date
L

luc.langlois

Hi

I have a problem with the FindNext function. The find is working fine,
but FindNext return nothing. Here's my code:

Set FindRes = Cells.Find(What:="0005", LookIn:=xlValues)
If Not FindRes Is Nothing Then
FirstAddress = FindRes.Address
Do
Set FindRes = Cells.FindNext(After:=FindRes)
Loop While Not FindRes Is Nothing And FindRes.Address <>
FirstAddress
End If

My function is call by a formula, If I move my code in a macro that I
call by the menu, everything goes fine.

Does soneone have an idea what shoul I do to have my code working? I've
tried with other parameters in the find call with no chance

Thanks

Luc
 
Hi Luc,
My function is call by a formula, If I move my code in a macro that I
call by the menu, everything goes fine.

Prior (I believe) to XL2002, Find could not be used in a worksheet function.
 
Hi Norman,

It seems that XL2003 have the same problem.

Thanks,

Luc

Norman Jones a écrit :
 
Are you sure that the find next is not working correctly? You are only
returning the very last cell found. You keep on overwriting your range object
with each FindNext...

If your intention is to return a range consisting of all of the found cells
then you need to use the union function to make one big range... If you need
help with that let me know...
 

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