Consulting

Results 1 to 3 of 3

Thread: Speed up loop?

  1. #1
    VBAX Regular
    Joined
    Jan 2009
    Posts
    89
    Location

    Speed up loop?

    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.

    [VBA]
    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
    [/VBA]

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Don't loop!

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

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Jan 2009
    Posts
    89
    Location
    WOW! Thank You!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •