Results 1 to 13 of 13

Make loop run faster

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-09-2009
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    188

    Make loop run faster

    Hi all. I need to see if I can make this loop any faster, but first, I have a question regarding this. I don't know why I did

    Dim Temp!, pTemp!, ema!
    What does that mean? I just want to know when to use the "!" .. If I define any of those as an Integer or a Long, it rounds the final answer to a whole number...so I have to use the above in order for the loop to work correctly. Why is that?

    Anyway, here is the loop. If someone can tell me how to make it run faster, I'd really appreciate that. Thank you!

    Sub exp20()
    
    Dim Temp!, pTemp!, ema!
    
    Application.ScreenUpdating = False
    
    LR = Cells(Rows.Count, "A").End(xlUp).Row
    
    EMAp = 10
    
    For i = 2 To LR - EMAp
        
        Temp = 0: pTemp = 0:
    
        For j = 1 To EMAp
            Temp = Cells(i + j - 1, 7).Value
            pTemp = pTemp + Temp
        Next j
        
        ema = pTemp / EMAp
        
    Cells(i, 12).Value = ema
    
    Next i
    
    Application.ScreenUpdating = True
    Last edited by Paul; 02-19-2010 at 11:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1