PDA

View Full Version : Speed up loop?



leal72
10-01-2009, 01:22 PM
My code is running slower than I would like, thinking maybe my loop needs some tweeking to speed things up. The variable LastRow and DataStart give me the row location fof the start and end data.


Dim LastRow As Long
Dim DataStart As Long
Dim x As Long

For x = DataStart To LastRow
Range("E" & x).FormulaR1C1 = "=ABS(RC[-2])"
Range("F" & x).FormulaR1C1 = "=ABS(RC[-2])"
Range("G" & x).FormulaR1C1 = "=RC[-2]/(R4C15*R6C15)"
Range("H" & x).FormulaR1C1 = "=RC[-2]/(R8C15)"
Range("I" & x).FormulaR1C1 = "=RC[-1]-(R30C14)"
Range("J" & x).FormulaR1C1 = "=RC[-1]*100"
Next x

mdmackillop
10-01-2009, 01:46 PM
Don't loop!


Range("E" & DataStart).Resize(LastRow + 1 - DataStart).FormulaR1C1 = "=ABS(RC[-2])"

leal72
10-01-2009, 01:54 PM
WOW! Thank You!