views:

72

answers:

1

Hello,

Is there much overhead involved in VBA classes? I noticed that on a previous workbooks I effectively did the same thing as what's currently in my classes, but it ran faster.

A: 

Hi Jake, To answer your question, there is a little overhead with classes. Namely the creation and destruction of those objects. Also accessing properties can be a wee bit slower. But generally speaking, it should be a fairly negligible amount. You really shouldn't see any difference at all unless you measuring in milliseconds. A more likely culperit is the way the code is now structured. I would advise stepping through the code and observing what it is actually doing. It could be possible there are things you can do to optimize the code.
To give an example: If you have a property that performs a look-up on a value that won't have changed consider having the first access of that property lookup up the value and store it for future reference. So any calls to that property thereafter don't have to perform the lookup. If you think the data may change, consider using a refresh method, or an optional refresh parameter.
This example may not apply to your specific situation, but you get the idea. You might consider posting your code and asking for help making it faster.

Oorang
Thanks for the help! Turns out a single line was effing everything up :S. Good to know classes don't add much overhead in any case.
JakeTheSnake