Hello!
I've been lurking these forums for quite some time, and found so many helpful. Now I'd like to ask for some help too.
I have a nasty array formula in cell c6, with matching time and different criteria, at first I autofilled it on my sheet which is around 5000 rows at max, but it took too much time for calculating, (I also copied values on them after calculation). I thought with a looping it would be quicker, which is slightly faster then autofilling the whole column, but I find calculating and copying cell by cell is too slow. Could you recommend any other workarounds or changes to my loop?
Thanks alot in advance.
my loop:
Sub calculate()
Dim lastrow As Long
Dim rowcurr As String
Dim rownext As String
Dim rowstart As String
Dim rowif As String
lastrow = Cells(Rows.Count, "d").End(xlUp).Row - 6
Range("c6").Select
rowcurr = ActiveCell.Address(0, 0)
rowstart = rowcurr
Range(rowcurr).Select
Selection.Offset(1).Select
rownext = ActiveCell.Address(0, 0)
Application.Calculation = xlManual
For x = 1 To lastrow
Range(rowcurr).Select
Selection.AutoFill Destination:=Range(rowcurr, rownext)
Calculate
Range(rownext).Select
Selection.Offset(-1).Select
rowif = ActiveCell.Address(0, 0)
If rowif = rowstart Then GoTo step Else
ActiveCell.Copy
Selection.PasteSpecial xlPasteValues
step:
Range(rownext).Select
rowcurr = ActiveCell.Address(0, 0)
Selection.Offset(1).Select
rownext = ActiveCell.Address(0, 0)
Next
Application.Calculation = Automatic
End Sub
I've been lurking these forums for quite some time, and found so many helpful. Now I'd like to ask for some help too.
I have a nasty array formula in cell c6, with matching time and different criteria, at first I autofilled it on my sheet which is around 5000 rows at max, but it took too much time for calculating, (I also copied values on them after calculation). I thought with a looping it would be quicker, which is slightly faster then autofilling the whole column, but I find calculating and copying cell by cell is too slow. Could you recommend any other workarounds or changes to my loop?
Thanks alot in advance.
my loop:
Sub calculate()
Dim lastrow As Long
Dim rowcurr As String
Dim rownext As String
Dim rowstart As String
Dim rowif As String
lastrow = Cells(Rows.Count, "d").End(xlUp).Row - 6
Range("c6").Select
rowcurr = ActiveCell.Address(0, 0)
rowstart = rowcurr
Range(rowcurr).Select
Selection.Offset(1).Select
rownext = ActiveCell.Address(0, 0)
Application.Calculation = xlManual
For x = 1 To lastrow
Range(rowcurr).Select
Selection.AutoFill Destination:=Range(rowcurr, rownext)
Calculate
Range(rownext).Select
Selection.Offset(-1).Select
rowif = ActiveCell.Address(0, 0)
If rowif = rowstart Then GoTo step Else
ActiveCell.Copy
Selection.PasteSpecial xlPasteValues
step:
Range(rownext).Select
rowcurr = ActiveCell.Address(0, 0)
Selection.Offset(1).Select
rownext = ActiveCell.Address(0, 0)
Next
Application.Calculation = Automatic
End Sub