Hello all,
I have been noticing the use of .FindNext more and more in recent code examples. I know that .FindNext looks a bit cleaner, but when I was learning VBA, I found that the .FindNext method was quite a bit slower (about 40% slower) than just using .Find over and over. I realize that seems a little counterintuitive, so I made a test workbook to verify if that was true or not.
Attached is a zip file containing the test workbook (had to zip it to get it under the 1 MB limit, test file is 4.46 MB).
The test file has 1 sheet with with just the word "text" in cells A1:E50000 (so 250,000 cells with just the word "text").
The file has 2 macros to test the speed of the different methods. The macros are identical except for one uses only the .Find method while the other uses the .FindNext method.
Find Only:
Please Login or Register to view this content.
FindNext:
Please Login or Register to view this content.
I ran each macro 3 times. Here were the results (in seconds)
Find Only (Average 9.792969):
10.015625
9.671875
9.69140625
FindNext (Average 13.88151):
13.89453125
13.875
13.875
As a result, I have always solely used .Find instead of .FindNext. Is there any reason or advantage to use .FindNext other than the code "looks better"?
[EDIT]
Adding system specs for reference regarding code run speed (this is the system that ran the test):
Windows XP Pro 2002 SP3
Intel Core2 Duo 2.99 GHz
3.49 GB of RAM
Excel 2007 SP3
Bookmarks