+ Reply to Thread
Results 1 to 10 of 10

Suddenly slower running code...

  1. #1
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Suddenly slower running code...

    Quick question... the code below was running fine in that it took about 2 seconds to do its job. Suddenly it now takes about 30 and I didn't change any of the code you see... From the VBA editor if I hit F8 and step through each line it seems to run fine with out hanging. It only runs poorly when started from the command button within the project.

    Another clue... If I run it from the command button, wait about 10 seconds and hit the "Esc" key.. the process stops and I get my copied page just fine. I also tried commenting out various lines but cant seem to find the issue...

    What other trouble shooting steps can I take to try and track this down???





    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Suddenly slower running code...

    Do you have any worksheet event procedures like Private Sub Worksheet_Change(ByVal Target As Range)

    What's the UsedRange of the copied sheet? If you filled say an entire column or row with a formula, it could take a long time to replace formulas with values for all the rows or all the columns.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Suddenly slower running code...

    All these lines are missing a colon. So I would expect it to error.

    This...
    ActiveSheet.Protect Password = "safe"

    Should be this...
    ActiveSheet.Protect Password:= "safe"

  4. #4
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Suddenly slower running code...

    Intresting you mention the event procedures, I did have one for another sheet that I ended up not using and to be safe, just commented it out... but nothing on the Tech Detail sheet I am copying. This sheet is dashboard style report that prints to 8-1/2 X 11, so nothing to huge. I have earlier versions of this same project that run fine... Something I did along the line caused this to happen...

  5. #5
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Suddenly slower running code...

    No error with out the colon! I added them but still have a macro that is hanging up... Crazy it runs fine from the editor.. Tried removing "Application.ScreenUpdating = False" and watch the process... no help..


    Also Tried removing this section as well as the password lines... no help.

    shname = Worksheets("Tech Detail").Range("i3")
    For Each sh In Worksheets
    If sh.Name Like shname Then flg = True: Exit For
    Next
    If flg = True Then
    MsgBox "A report already exsisits for " & shname
    ActiveSheet.Protect Password = "safe"
    Exit Sub
    Else

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Suddenly slower running code...

    What's the used range area?

    Please Login or Register  to view this content.

    The .Protect lines need the colon as well. Otherwise the password is "False" and not safe.
    ActiveSheet.Protect Password:= "safe"


    This without the colon Password = "safe" evaluates to False
    Last edited by AlphaFrog; 04-10-2014 at 10:52 PM.

  7. #7
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Suddenly slower running code...

    $A$1 $X$73 I made a copy and deleted every formula and chart off the tech Detail sheet and it still runs slow. There is one cell set up as a data validation to a list of techs you would choose from. Cant seem to delete that...

  8. #8
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Suddenly slower running code...

    I have auto calculation disabled as it takes about 20 seconds for this workbook to calculate.. (lots of big sumproduct formulas) I just noticed it seems to recalculating while the macro is running... can that be surpressed while the code is running?

  9. #9
    Registered User
    Join Date
    01-18-2014
    Location
    Chicago
    MS-Off Ver
    Excel 2013
    Posts
    88

    Re: Suddenly slower running code...

    AlphaFrog, I have to apologize... I talked my way into the fix... somehow I had auto re calculation turned back on...

    Thank you for taking the time to help me focus on finding what I did to cause this!

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Suddenly slower running code...

    Quote Originally Posted by fgruhlke View Post
    I have auto calculation disabled as it takes about 20 seconds for this workbook to calculate.. (lots of big sumproduct formulas) I just noticed it seems to recalculating while the macro is running... can that be surpressed while the code is running?
    It could be the calculations.

    This something like this

    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)

Similar Threads

  1. Excel is suddenly running very slow
    By MSP in forum Excel General
    Replies: 13
    Last Post: 03-10-2022, 04:35 PM
  2. Excel macro getting slower and slower.
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-24-2011, 06:41 AM
  3. Why is code in .xlsm slower than .xls in excel 2007
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-31-2010, 10:03 AM
  4. Macros running much slower in 2007/Win7
    By surfengine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2010, 05:51 PM
  5. VBA routine gets slower and slower on each iteration of the main loop
    By whitespaces in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-15-2009, 03:29 AM

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