Greetings:

I am in the process of moving a program from Excel VBA to VBE 2005.

In each, I run numerous iterations of calculations over multiple years. Listed below is the heart of the computations, but there are many others that are standard addition, division, multiplication, etc.

For i = 1 To Iterations

For j = 1 To Years

Counter = Counter + 1

MyArray(i, j) = 1 + (InvRet + (((Math.Sqrt(-2 * objExcel.Application.WorksheetFunction.Ln(Rnd()))) * (Math.Cos(6.28318 * Rnd()))) * StdDev))

Next j

Next i

If you're interested, this is a Box-Muller transformation of a uniform distribution into a normal distribution.

In Excel VBA this program takes about 7 seconds to run 30 years with 2,000 iterations per year, plus all the other calculations in Excel VBA.

In VBE 2005, this same program with 30 years and 2,000 iterations in each year takes almost 2 minutes and 20 seconds to run.

Is there any way to speed up this VBE 2005 code/formula above

Thanks in advance for any suggestions.

Glenn