View Single Post
 
Old 05-29-2017, 09:10 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I didn't try to read the whole program to see which techniques you used. But here's a quick list of the things I do to speed up an Excel VBA program:

1) Turn off screen updating (Application.ScreenUpdating); I see you're doing that already.

2) It often helps to turn off automatic calculation (Application.Calculation=xlCalculationManual).

Don't forget to restore these at the end of your program, or if you're abending. I keep a class around to handle both of these settings and a few more; it automatically detects and saves the status of each setting when it's created, and includes a method I can call at the end of the program or during Abend to restore them all before quitting.

3) If you're reading or writing large amounts of data, say more than 100 cells, this one makes a huge difference: Whenever possible, read a range into a two-dimensional array (it has to be two dimensions even if you're looking only at a single column or row), process it there, and write the array back to a range. This is more work at the programming end, but it can turn a three-minute program into a half-second program—well worth the trouble if you're going to use it more than once, and after you get used to using arrays you'll have the techniques down pat and won't think it much of an extra burden.

4) I have the feeling I'm missing one, but I can't remember...
Reply With Quote