+ Reply to Thread
Results 1 to 19 of 19

Excel Freezes After Running Macro

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Excel Freezes After Running Macro

    Hello,

    I have a macro in a Worksheet Change.
    It works fine, but, as soon as the macro stops running, the screen get frozen for few seconds (even the VBA Editor).
    I can't get why this happens, any clue?

    I already tried with the DoEvents at the beginning of the Sub.
    I have many Application.EnableEvents (and Application.ScreenUpdating) because they prevent the Worskheets Change to start again when I write (through the code) something in the sheet.
    In any case, at the and of the sub I set bot of the as "True".
    The code is too long to be attached here, let me know if needed.

    Thanks
    Regards
    Attached Files Attached Files
    Last edited by BrianAll; 02-11-2020 at 11:11 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    It's pretty hard to debug it when we can't see it.
    Rory

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    You should find the Sub attached.
    Thanks!

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    Um, nope.

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    .cls was invalid format.
    I attached a .txt

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    Does the freeze happen no matter what cell you change?

  7. #7
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    @rorya
    Yes...

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    I can't test that code in isolation as it calls other code and uses variables that aren't declared - can you post the workbook?

  9. #9
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    Hello,
    it contains sensitive data.
    I attached the code of the Call routine.
    I hope it helps.

    Thanks!
    Attached Files Attached Files

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    I don't need any data in the file, just the structure including formulas and formatting. Otherwise I have to try and go through all of your code to create the necessary worksheets to prevent errors and it likely still won't reproduce your issue.

  11. #11
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    Here is the file.
    I think it will crash but I still hope it helps..
    Attached Files Attached Files

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    It doesn't crash, but also doesn't display any lag for me. Does that sample still exhibit the problem for you? If so, try starting Excel in safe mode and see if it still has the issue when using the workbook.

  13. #13
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    Nope. Any lag.
    I tried to clean the workbook in order to leave just one working example to show you and it still doesn't show any lag...

    I have an almost identical copy of the whole file. One is showing lag, the other one not. Any clue on this?

  14. #14
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    I suspect the clue will be in the "almost" part of "almost identical". What's different? Lags like that are usually down to something like recalculation - does one have volatile formulas that the other doesn't?

  15. #15
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    Nope, no formulas.
    Just different set of data in one sheet but they have also the same DB (where to search when Target.Column is = 2 and the value = "Interno").
    I even tried with Application.Calculation = xlCalculationManual. No clue.

    The problem is within the Call.
    I set an interruption before the Call. Up to there, everything runs smoothly.
    I set a code interruption on the line below the Call --> the macro is performed fine, the cursor reaches the stop and the line is highlighted in yellow. But still it takes few second to allow me doing anything (i.e. pressing F8 to continue step by step).

  16. #16
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel Freezes After Running Macro

    The only thing I can think of at this point would be the conditional formatting on one of your sheets. Try deleting that (in a copy of your workbook) and then see if the behaviour persists.

    Your called code is not particularly efficient, but there's nothing in there that would keep running after the call to it had completed.

  17. #17
    Registered User
    Join Date
    06-19-2013
    Location
    Sheffield
    MS-Off Ver
    Excel 2013
    Posts
    86

    Re: Excel Freezes After Running Macro

    Hi rorya.
    Great point!
    Without conditional formatting a small lag persists but it's remarkably faster.
    Any hint about preventing this through VBA without deleting all conditional formatting rules? (Maybe I can use a worksheet change instead of conditional formatting where needed…)

    (Yeah, I know it is not effecient at all. I wrote it in different steps, I should take few moments and "clean it up").

  18. #18
    Registered User
    Join Date
    12-12-2013
    Location
    Tasmania
    MS-Off Ver
    Excel 365
    Posts
    3

    Re: Excel Freezes After Running Macro

    Did you ever solve this? I think I've got the same problem... I'm new here and not sure what the etiquette is; should I ask here or start a new post?

    I have a macro that creates about 50 sheets. It executes quickly, and there is no hang immediately on completion, but upon the first change made to a cell after that it hangs for about 15 seconds, then goes back to normal for subsequent changes.

    I suspected it was just recalculating for the first time after so many changes to the spreadsheet (I turn screen updating and calculating off at the start of the macro, and back on at the end), but I've tried to force it to recalculate just before exiting the macro and that didn't help. I've tried the following lines of code in every imaginable order:

    Please Login or Register  to view this content.
    I've also tried putting this at the very end of the macro to simulate changing a cell after the macro has finished:

    Please Login or Register  to view this content.
    But nothing works. Any clues?

  19. #19
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Excel Freezes After Running Macro

    Quote Originally Posted by hot toddy View Post
    Did you ever solve this? I think I've got the same problem... I'm new here and not sure what the etiquette is; should I ask here or start a new post?...
    Welcome, and yes, please start a new thread, otherwise it's considered highjacking to ask a question on another member's thread. Quote the link to this thread if you think it would be relevant
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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 freezes upon activating macro
    By GergesT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2018, 03:53 AM
  2. Macro to extract numbers freezes excel
    By ohandy1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-13-2017, 04:41 PM
  3. Excel Freezes During Print Macro
    By dboatman_z in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 01:11 PM
  4. excel freezes after updating cells and runing macro
    By sfcleon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-08-2013, 03:06 PM
  5. VBE freezes after running macros
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2013, 11:15 AM
  6. Simple macro (ClearContent) freezes Excel
    By bokodilaszlo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2006, 09:24 AM
  7. Macro freezes up Excel
    By Jon Delano in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2005, 03:05 PM

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