Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Alan,
Find next will give problems if you re-order your data after the initial find and before Find next. Other options are to repeat the find line of code instead of using Find next. Include 'After' parameter which will be the address of the last find after the re-ordering of the data. As a further tip, it is recommended that you include all of the parameters in Find because Excel remembers them from the previous use even if it was in the interactive mode. Use Record Macro to find the parameters to include. You will have to modify the code a bit to use it in the same way that you have in your example but it is an easy way to get the parameters right. -- Regards, OssieMac "AlanC" wrote: I am having difficulty in understanding the .FIND example in the help files. With Worksheets(1).Range("a1:a500") Set c = .Find(2, lookin:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do c.Value = 5 Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With This works fine but in my case I need to do some reordering of rows and then continue to FINDNEXT. There appears to be a pointer set within the FIND method which is where the .Findnext(c) starts. My changes mean that the pointer is set to a row before the found occurrence and thus the .Findnext repeats or at the end of the range the repeat finds a different address for the c.address from that stored in firstaddress so loops continuously. Is the pointer addressable, modificable or am I going about it the wrong way? -- AlanC |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Understanding formula | Excel Worksheet Functions | |||
Not understanding with/end with | Excel Programming | |||
Not understanding If Not..Then nothing | Excel Programming | |||
Understanding Templates | Excel Programming | |||
Understanding declarations | Excel Programming |