VBA, Memory and Speed
Microsoft's VBA (Visual Basic for Applications) is clunky and slow, but occasionally, it is the right tool for the job, particularly for cleaning up data that is stored in an Excel format. One of the problems with VBA, however, is that it tends to suck up memory. Anyone who uses VBA to play with data sets with more than a few thousand observations will run into the problem of seeing their program slow down more and more. In fact, if you run the same program multiple times in a row, you will find it runs slower each time you run it. If your data set is large enough, or your code runs through enough calculations, you will eventually get an out of memory message and the whole thing crashes. It turns out there is a simple solution to this irritating problem. However, to fix the problem, you have to understand why it exists, which is that Excel has an undo function which also extends into VBA. In order to undo a step, Excel "remembers" the old state, so it can return