
Originally Posted by
PcMax
I'm using the following code
Code:
Option Explicit
Sub CTest()
Dim r As Long
Dim ka, k()
Dim i As Long
r = Range("C" & Rows.Count).End(3).Row + 1
ka = Range("C3:C" & r)
ReDim k(1 To UBound(ka, 1), 1 To 1)
For i = 1 To UBound(ka, 1) - 1
k(i, 1) = ka(i + 1, 1) - ka(i, 1)
Next
Range("O3").Resize(UBound(k, 1)) = k
End Sub
I doubt if the time difference is measurable, but given what you are doing, you do not need the k array... just do your calculations back into the ka array itself...
Code:
Sub CTest()
Dim r As Long
Dim ka
Dim i As Long
r = Range("C" & Rows.Count).End(3).Row + 1
ka = Range("C3:C" & r)
For i = 1 To UBound(ka, 1) - 1
ka(i, 1) = ka(i + 1, 1) - ka(i, 1)
Next
Range("O3").Resize(UBound(ka, 1)) = ka
End Sub
Bookmarks