Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
An alternative approach that should be orders of magnitude faster
would be to sort the data ascending or descending on column 1 and descending on column 2, then use this formula (its not an array formula) in column D shDAT.Range("D2").Formula="=IF($A2<$A1,$B2,$B1)" shDAT.Range("D2").AutoFill Destination:=shDAT.Range("D2:D" & r), Type:=xlFillDefault Charles The code is now: r = shDAT.UsedRange.Rows.Count shDAT.Range("D2").FormulaArray = "=MAX(IF(R2C1:R" & r & "C1=RC1,R2C2:R" & r & "C2,FALSE))" shDAT.Range("D2").AutoFill Destination:=shDAT.Range("D2:D" & r), Type:=xlFillDefault Execution of this part of the code is now a magnitude faster, and it produces exactly the same result. Calculation at the end of the code (when calculation is set to xlCalculationAutomatic again) is of course still slow, but this is expected. One does not simply walk into 10K array formulas and expect it to be fast. ;-) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Code Editor Slows execution speed | Excel Programming | |||
Code slows down after a few runs | Excel Programming | |||
PrintPreview slows Code Execution | Excel Programming | |||
ActiveCell.FormulaArray code - Get error | Excel Programming | |||
Code slows on subsequent run | Excel Programming |