Speeding up excel v...
 

MegaSack DRAW - This year's winner is user - rgwb
We will be in touch

[Closed] Speeding up excel vba

12 Posts
9 Users
0 Reactions
74 Views
 mrmo
Posts: 10710
Free Member
Topic starter
 

Is their any way, missing comments etc. to get a vba script to run a bit quicker? The one I have is reasonably quick but because of the size of the worksheet it is taking a while!


 
Posted : 12/05/2011 2:06 pm
Posts: 91097
Free Member
 

There could be, but it depends on what the code does!

It's like asking how could you make a novel shorter.


 
Posted : 12/05/2011 2:08 pm
Posts: 151
Free Member
 

By far the cheapest approach is to buy a better PC (assuming this isn't for personal use).


 
Posted : 12/05/2011 2:09 pm
Posts: 2
Free Member
 

Get a better vba programmer...
Get a better computer...
Turn off everything else on your computer.
Probably in that order to.


 
Posted : 12/05/2011 2:10 pm
 mrmo
Posts: 10710
Free Member
Topic starter
 

It is a two condition lookup, find match in column one, look in column two for a second match. Small detail is comparing two tables with 10000 rows each. I need to find rows that don't match.


 
Posted : 12/05/2011 2:12 pm
Posts: 2
Free Member
 

How are you doing it?


 
Posted : 12/05/2011 2:14 pm
Posts: 91097
Free Member
 

That sounds like it could be significantly optimised. How are you looking for things?

Oh, and you say 'tables' - I presume you mean worksheets?


 
Posted : 12/05/2011 2:15 pm
Posts: 0
Free Member
 

Don't delete comments!

Turn off screen updating while you do the heavy lifting (and turn it on again afterwards).


 
Posted : 12/05/2011 2:32 pm
Posts: 10
Full Member
 

2nd turning off the screen updating, seems to slow things right down. (to me) it always looks magical when the end thing suddenly appears on the screen 🙄


 
Posted : 12/05/2011 2:37 pm
Posts: 6332
Free Member
 

can you do it in Excel, rather than VBA?


 
Posted : 12/05/2011 2:44 pm
Posts: 2
Free Member
 

Sounds like 2 vlookups would work. But I think 2 collections in VBA would work quicker.


 
Posted : 12/05/2011 2:48 pm
Posts: 6817
Full Member
 

Junk the looks ups, use the vba to run down the columns until it finds a match.

Another way of massively speeding up the code in a large workbook is to switch off automatic calculation when the macro is running. Obviously if the macro is using the results from a work book formula this doesn't wotk so well although you can get the VBA to calculate the results for a specific formula as part of the code. Don't forget to turn the automatic calculation back on at the end of the macro. If the macro crashes don't forget to turn it back on manually.


 
Posted : 12/05/2011 3:22 pm
Posts: 13594
Free Member
 

its faster to use worksheet functions, called from VBA, than to implement them yourself eg worksheetfunction.vlookup etc


 
Posted : 12/05/2011 3:23 pm