PDA

View Full Version : Sleeper: Problem with multiple .find statements?



uksrogers
07-26-2006, 09:46 AM
Hi there,

I have been working on a macro recently, trying to get the best performance out of it but seem to have run into a problem.

The process i follow is to open a csv file in excel (as long as it isn't > 65530 lines) and search, using .find on column 1. Every time i find a particular code (TA), this signifies the information between the two TA codes should go on a separate sheet. The data is copied from the csv file to a template sheet which is then processed (formatted) before returning to the csv file to find the next TA.

When i am formatting the template sheet, one of the rows will contain values 0 | 0 | 1 | 1 | 1 | 0 | 0 for example. The value 1 stipulates that the column should have a filter applied to it.

Previously i would go into a loop and interrogate each value to get the first and last column values (column 3 - 5 in the example above). I decided to change this and try another .find as this would simplify things greatly.

The problem i am finding now is that when the macro returns to the first .find statement (the one that is picking out the "TA" lines), when it tries to do a .findnext, the variable is being set to nothing, despite the fact that there are more things to find.

It is almost as if, once the second find is completing it is affecting the results of the first find.

For info - the two find statements are in separate procedures with their own private variables defined. The variables even have different names!

Sorry for the essay, but any thoughts or ideas would be appreciated.

Regards

uksrogers

Aaron Blood
07-26-2006, 10:45 AM
I just wrapped the whole thing up with a little function and don't bother with it anymore...

http://www.xl-logic.com/xl_files/vba/kickbutt_find_function.zip

Working with FoundRange objects is easier.

uksrogers
07-26-2006, 02:07 PM
Ahh.. interesting.. will have a look at that.. thanks.

uksrogers