Quick question, for the below, the second loop is faster than the first.
Is this due to the overhead associated with the Variant type? - Granted it's not much slower though
Sub DirectArray() Dim arr(1 To 10000) As Long Dim rngArr Dim x As Long Dim y As Long Dim t As Class1 For x = 1 To 10000 arr(x) = x Next x rngArr = Application.Transpose(Sheet2.Range("A1:A10000").Value) Set t = New Class1 With t .StartCounter For x = 1 To 10000 y = rngArr(x) + y Next x Debug.Print "rngArr: " & .TimeElapsed y = 0 .StartCounter For x = 1 To 10000 y = arr(x) + y Next x Debug.Print "arr: " & .TimeElapsed End With End Sub
Last edited by Kyle123; 01-26-2012 at 08:50 AM.
Click the * below to say thanks
Girls sleep with guys who use photoshop, but marry the ones who work with Excel
Corduroy pillows: They're making headlines!
Did you mean: recursion
http://www.google.com/search?hl=en&q=recursion
Yes - you are having to coerce data types to do the arithmetic.
Good luck.
Cheers, that's what I thought![]()
Click the * below to say thanks
Girls sleep with guys who use photoshop, but marry the ones who work with Excel
Corduroy pillows: They're making headlines!
Did you mean: recursion
http://www.google.com/search?hl=en&q=recursion
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks