VBA For loop using Find is slow. Suggestions for speeding up requested.

Spamz

New Member
Joined
Mar 17, 2009
Messages
4
I'm using Excel 2003. My macro takes a 40,000 line (approx) CSV file, and among other things finds rows with 10 keywords in the row and deletes the entire row.

The problem I want to solve is that the find loop is very very slow. It takes about 1-2 seconds per row to search through all my keywords. 40,000/60/60 = 11 hours.

The find operation is slower with the more words I add, but even with just one or two words, it was kind of slow. I have found that the find/replace command is much quicker, but I can't delete entire rows with that method and that is what I must do.

My approach uses a for each loop to iterate through each row. From there, I use a loop to find each of my key words in that row. Keywords are stored in an array.

Help to speed up this process would be appreciated!

Gabe
 
Hi Colin!

Thanks as well for this tip, you saved my day! I still don't understand why writing line-by-line makes Excel slower and slower, but at least this workaround works perfectly!
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,216,090
Messages
6,128,765
Members
449,467
Latest member
sdafasfasdf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top