+ Reply to Thread
Results 1 to 4 of 4

program running extremely slow

  1. #1
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    program running extremely slow

    Hello all.

    I wrote what I thought was a pretty simple procedure to pull out selected info. from a colleague's report. I'm not finished yet, but the rest of the program would be much of the same from the first part. However, it runs very slow so before I continue I wanted some assistance with finding out what's causing the slow-down. I would greatly appreciate any guidance you can provide. Thanks!

    Sub PDTrendingCalculate()
    Range("Q2") = "#"
    Range("R2") = "Week"
    Range("S2") = "Pre-Procedure PDs"
    Range("T2") = "Index Procedure PDs"
    Range("U2") = "Discharge PDs"
    Range("V2") = "30D PDs"
    Range("W2") = "6M PDs"
    Range("X2") = "Revascularization PDs"
    Range("Y2") = "#Pts"
    Range("Z2") = "Pre-Procedure Value"
    Range("AA2") = "Index Procedure Value"
    Range("AB2") = "Discharge Value"
    Range("AC2") = "30D Value"
    Range("AD2") = "6M Value"
    Range("AE2") = "Revascularization Value"
    Range("Q2:AE2").Select
    With Selection
    .Font.Bold = True
    End With
    Columns("S:AE").EntireColumn.AutoFit
    Range("Q3").Select
    ActiveCell = 1
    Do
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1
    Loop Until IsEmpty(ActiveCell.Offset(1, 8))
    Range("R3").Select
    ActiveCell = "4/6/2009"
    Do
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 7
    Loop Until IsEmpty(ActiveCell.Offset(1, 7))
    Range("S3").Select
    Do
    ActiveCell.FormulaR1C1 = _
    "=SUMPRODUCT(--(R3C7:R3000C7+0>=OFFSET(RC,0,-1)),--(R3C7:R3000C7+0<=(OFFSET(RC,0,-1)+6)),--(R3C10:R3000C10=""Pre-procedure""))"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(1, 6))
    Range("Z3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-1]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    Range("AA3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-2]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    Range("AB3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-3]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    Range("AC3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-4]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    Range("AD3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-5]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    Range("AE3").Select
    Do
    ActiveCell.FormulaR1C1 = "=RC[-7]/RC[-6]"
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell.Offset(0, -1))
    End Sub

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: program running extremely slow

    Hi Toidz77. Welcome. Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above and put code tags around that code you used. (like this...)
    Please Login or Register  to view this content.
    Also, that code will be far more meaningful if we could see it in action. Click GO ADVANCED and use the paperclip icon to post up your workbook.
    Last edited by JBeaucaire; 08-22-2009 at 10:11 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: program running extremely slow

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: program running extremely slow

    My apologies. The code I previously listed was changed to ehance the speed a bit and I'm happy with the performance ("PDTrendingCalculate") . The other code ("MakePivotTable"), however, runs even slower. I'm new to all of this so I would appreciate your expert guidance. For some background, the first code calculate's data from a colleague's report and the second uses that as source for a pivot table. The pivot table takes quite a while to complete.

    Thanks in advance for your time and guidance.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ Reply to Thread

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