Another important thing you can do in VBA is to use Option Explicit and avoid options where possible. In VBA, options are not eliminated 100%, but they make the interpreter work more during runtime and in memory.
I found this article very useful when I started with VBA in Excel.
http://www.ozgrid.com/VBA/SpeedingUpVBACode.htm
And this book
http://www.amazon.com/VB-VBA-Nutshell-Language-OReilly/dp/1565923588
Similarly
app.ScreenUpdates = false //and app.Calculation = xlCalculationManual
you can also install
app.EnableEvents = false //Prevent Excel events app.Interactive = false //Prevent user clicks and keystrokes
although they do not seem as large as the first two.
Similar to setting range values ββto arrays, if you work with data, which is basically tables with the same formula in each row of a column, you can use the formula formula R1C1 for your formula and set the full column equal to the string formula to set it all in one call.
app.ReferenceStyle = xlR1C1 app.ActiveSheet.Columns(2) = "=SUBSTITUTE(C[-1],"foo","bar")"
In addition, creating XLL add-ins using ExcelDNA and .NET (or the hard path in C) is also the only way that UDFs can run on multiple threads. (See Excel DNA Attribute Property ExcelFunction for IsThreadSafe Property.)
Before I completely switched to Excel DNA, I also experimented with creating COM visible libraries in .NET for reference in VBA projects. Heavy text processing is slightly faster than VBA, since wrapped .NET List classes are used instead of VBA Collection, but Excel is better.
JamesFaix Jul 16 '15 at 23:36 2015-07-16 23:36
source share