Macros in Excel 2010 hangs












2















I have a spreadsheet with several macros. Generally, when previously using Excel 2007, a user clicks a button and everything works as expected (calculations, some email sending & file I/O). Typically, the expected run-time is about 90 seconds. The spreadsheet is a xlsm file created with Excel 2007.



With Excel 2010 however, the same user process results in a non-responsive excel and forces us to kill excel from the task manager.



Some note that I have gathered so far in trying to debug this issue:




  1. When monitoring CPU usage, it seems that Excel does start the macro. CPU usage increases as expected to about 47% for a few seconds. Excel.exe than drops to 0% usage and I now have a non-responsive Excel (even after 1 hour).

  2. If I set debug break points across modules and different functions and step through the code (after clicking the button) , the process works as expected albeit much slower. To add, there were no exceptions.


I am at a complete loss as to what the issue may be. I initially thought it may be the add in that is being used but that was debunked by point 2.



This seems to be a very odd situation. I can provide more information if required, but I'm at wits end about the root cause could be. I need help in diagnosing and resolving this issue.










share|improve this question

























  • on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

    – Xantec
    Mar 16 '11 at 20:33











  • @xantec - what do you mean "line breaks"? The screen updating is a good idea though...

    – Ahmad
    Mar 17 '11 at 4:36











  • @Ahmed sorry, "line breaks" = "debug break points"

    – Xantec
    Mar 17 '11 at 13:10











  • I have the exact same situation - xlsm created in 2007 hangs my 2010.

    – x0n
    Sep 7 '11 at 21:03






  • 1





    @Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

    – Peter Albert
    Jan 13 '13 at 20:29
















2















I have a spreadsheet with several macros. Generally, when previously using Excel 2007, a user clicks a button and everything works as expected (calculations, some email sending & file I/O). Typically, the expected run-time is about 90 seconds. The spreadsheet is a xlsm file created with Excel 2007.



With Excel 2010 however, the same user process results in a non-responsive excel and forces us to kill excel from the task manager.



Some note that I have gathered so far in trying to debug this issue:




  1. When monitoring CPU usage, it seems that Excel does start the macro. CPU usage increases as expected to about 47% for a few seconds. Excel.exe than drops to 0% usage and I now have a non-responsive Excel (even after 1 hour).

  2. If I set debug break points across modules and different functions and step through the code (after clicking the button) , the process works as expected albeit much slower. To add, there were no exceptions.


I am at a complete loss as to what the issue may be. I initially thought it may be the add in that is being used but that was debunked by point 2.



This seems to be a very odd situation. I can provide more information if required, but I'm at wits end about the root cause could be. I need help in diagnosing and resolving this issue.










share|improve this question

























  • on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

    – Xantec
    Mar 16 '11 at 20:33











  • @xantec - what do you mean "line breaks"? The screen updating is a good idea though...

    – Ahmad
    Mar 17 '11 at 4:36











  • @Ahmed sorry, "line breaks" = "debug break points"

    – Xantec
    Mar 17 '11 at 13:10











  • I have the exact same situation - xlsm created in 2007 hangs my 2010.

    – x0n
    Sep 7 '11 at 21:03






  • 1





    @Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

    – Peter Albert
    Jan 13 '13 at 20:29














2












2








2








I have a spreadsheet with several macros. Generally, when previously using Excel 2007, a user clicks a button and everything works as expected (calculations, some email sending & file I/O). Typically, the expected run-time is about 90 seconds. The spreadsheet is a xlsm file created with Excel 2007.



With Excel 2010 however, the same user process results in a non-responsive excel and forces us to kill excel from the task manager.



Some note that I have gathered so far in trying to debug this issue:




  1. When monitoring CPU usage, it seems that Excel does start the macro. CPU usage increases as expected to about 47% for a few seconds. Excel.exe than drops to 0% usage and I now have a non-responsive Excel (even after 1 hour).

  2. If I set debug break points across modules and different functions and step through the code (after clicking the button) , the process works as expected albeit much slower. To add, there were no exceptions.


I am at a complete loss as to what the issue may be. I initially thought it may be the add in that is being used but that was debunked by point 2.



This seems to be a very odd situation. I can provide more information if required, but I'm at wits end about the root cause could be. I need help in diagnosing and resolving this issue.










share|improve this question
















I have a spreadsheet with several macros. Generally, when previously using Excel 2007, a user clicks a button and everything works as expected (calculations, some email sending & file I/O). Typically, the expected run-time is about 90 seconds. The spreadsheet is a xlsm file created with Excel 2007.



With Excel 2010 however, the same user process results in a non-responsive excel and forces us to kill excel from the task manager.



Some note that I have gathered so far in trying to debug this issue:




  1. When monitoring CPU usage, it seems that Excel does start the macro. CPU usage increases as expected to about 47% for a few seconds. Excel.exe than drops to 0% usage and I now have a non-responsive Excel (even after 1 hour).

  2. If I set debug break points across modules and different functions and step through the code (after clicking the button) , the process works as expected albeit much slower. To add, there were no exceptions.


I am at a complete loss as to what the issue may be. I initially thought it may be the add in that is being used but that was debunked by point 2.



This seems to be a very odd situation. I can provide more information if required, but I'm at wits end about the root cause could be. I need help in diagnosing and resolving this issue.







microsoft-excel microsoft-excel-2010 vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 '12 at 13:07









Raystafarian

19.4k104989




19.4k104989










asked Mar 16 '11 at 10:25









AhmadAhmad

4261614




4261614













  • on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

    – Xantec
    Mar 16 '11 at 20:33











  • @xantec - what do you mean "line breaks"? The screen updating is a good idea though...

    – Ahmad
    Mar 17 '11 at 4:36











  • @Ahmed sorry, "line breaks" = "debug break points"

    – Xantec
    Mar 17 '11 at 13:10











  • I have the exact same situation - xlsm created in 2007 hangs my 2010.

    – x0n
    Sep 7 '11 at 21:03






  • 1





    @Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

    – Peter Albert
    Jan 13 '13 at 20:29



















  • on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

    – Xantec
    Mar 16 '11 at 20:33











  • @xantec - what do you mean "line breaks"? The screen updating is a good idea though...

    – Ahmad
    Mar 17 '11 at 4:36











  • @Ahmed sorry, "line breaks" = "debug break points"

    – Xantec
    Mar 17 '11 at 13:10











  • I have the exact same situation - xlsm created in 2007 hangs my 2010.

    – x0n
    Sep 7 '11 at 21:03






  • 1





    @Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

    – Peter Albert
    Jan 13 '13 at 20:29

















on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

– Xantec
Mar 16 '11 at 20:33





on occasion i run into similar issues, usually caused by one process not completing before the macro continues, thus leaving something out of place (line breaks actually help the issue because it gives the process a chance to complete). i would recommend commenting out any lines that disable screen updating so that you can watch the macro in action. hopefully this will give you a better idea of where it is hanging.

– Xantec
Mar 16 '11 at 20:33













@xantec - what do you mean "line breaks"? The screen updating is a good idea though...

– Ahmad
Mar 17 '11 at 4:36





@xantec - what do you mean "line breaks"? The screen updating is a good idea though...

– Ahmad
Mar 17 '11 at 4:36













@Ahmed sorry, "line breaks" = "debug break points"

– Xantec
Mar 17 '11 at 13:10





@Ahmed sorry, "line breaks" = "debug break points"

– Xantec
Mar 17 '11 at 13:10













I have the exact same situation - xlsm created in 2007 hangs my 2010.

– x0n
Sep 7 '11 at 21:03





I have the exact same situation - xlsm created in 2007 hangs my 2010.

– x0n
Sep 7 '11 at 21:03




1




1





@Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

– Peter Albert
Jan 13 '13 at 20:29





@Ahmad, in addition to the .ScreenUpdating=True and the debug by elimination, try inserting Debug.Print Now(), 'some marker text' every few lines. Then take a look at the Immediate window while the code is running and see if and where it stalls. Then narrow it down in the area it stalls by adding more print statements/eliminating some code.

– Peter Albert
Jan 13 '13 at 20:29










3 Answers
3






active

oldest

votes


















0














This may not be your answer, but it is a situation that I have seen that produces the results you've described.



Look in the macro(s) for the following statement:



Application.ScreenUpdating = False


This tells the Excel GUI interface to not show any changes/updates/anything that is going on. This can be desirable while a macro runs. However, you have to make sure the macro at some point sets this back to true like this:



Application.ScreenUpdating = True


If this is never set back to True, then it produces a situation like you've described.



First search the code for the 'ScreenUpdating' property being set, remove it, and see if that fixes the issue.



If you don't find 'ScreenUpdating' anywhere in the code, then you have some other problem.



Edit: Looks like someone already mentioned screen updating in the comments above.






share|improve this answer































    0














    Thanks for this help.



    I was running a macro in development and live. I had no issue in DEV but it hung in live. It runs on a server rather than a local PC. I recall that when we first tried it in live we had to kill the task and it hung on subsequent retries. As soon as I added the lines
    application.screenupdating = TRUE
    doevents()
    doevents()



    immediately before
    application.screenupdating = FALSE



    the macro has worked as intended.






    share|improve this answer































      0














      In addition to the previous mentioned answers, If your excel sheet contains a fairly large amounts of data try saving it as an Excel Binary Worksbook (*.xlsb)



      The binary format is a lot more faster than the standard xml format of excel. Hopefully your macros will be able to run faster too.






      share|improve this answer
























      • Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

        – DavidPostill
        Nov 15 '16 at 11:57











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f258259%2fmacros-in-excel-2010-hangs%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      This may not be your answer, but it is a situation that I have seen that produces the results you've described.



      Look in the macro(s) for the following statement:



      Application.ScreenUpdating = False


      This tells the Excel GUI interface to not show any changes/updates/anything that is going on. This can be desirable while a macro runs. However, you have to make sure the macro at some point sets this back to true like this:



      Application.ScreenUpdating = True


      If this is never set back to True, then it produces a situation like you've described.



      First search the code for the 'ScreenUpdating' property being set, remove it, and see if that fixes the issue.



      If you don't find 'ScreenUpdating' anywhere in the code, then you have some other problem.



      Edit: Looks like someone already mentioned screen updating in the comments above.






      share|improve this answer




























        0














        This may not be your answer, but it is a situation that I have seen that produces the results you've described.



        Look in the macro(s) for the following statement:



        Application.ScreenUpdating = False


        This tells the Excel GUI interface to not show any changes/updates/anything that is going on. This can be desirable while a macro runs. However, you have to make sure the macro at some point sets this back to true like this:



        Application.ScreenUpdating = True


        If this is never set back to True, then it produces a situation like you've described.



        First search the code for the 'ScreenUpdating' property being set, remove it, and see if that fixes the issue.



        If you don't find 'ScreenUpdating' anywhere in the code, then you have some other problem.



        Edit: Looks like someone already mentioned screen updating in the comments above.






        share|improve this answer


























          0












          0








          0







          This may not be your answer, but it is a situation that I have seen that produces the results you've described.



          Look in the macro(s) for the following statement:



          Application.ScreenUpdating = False


          This tells the Excel GUI interface to not show any changes/updates/anything that is going on. This can be desirable while a macro runs. However, you have to make sure the macro at some point sets this back to true like this:



          Application.ScreenUpdating = True


          If this is never set back to True, then it produces a situation like you've described.



          First search the code for the 'ScreenUpdating' property being set, remove it, and see if that fixes the issue.



          If you don't find 'ScreenUpdating' anywhere in the code, then you have some other problem.



          Edit: Looks like someone already mentioned screen updating in the comments above.






          share|improve this answer













          This may not be your answer, but it is a situation that I have seen that produces the results you've described.



          Look in the macro(s) for the following statement:



          Application.ScreenUpdating = False


          This tells the Excel GUI interface to not show any changes/updates/anything that is going on. This can be desirable while a macro runs. However, you have to make sure the macro at some point sets this back to true like this:



          Application.ScreenUpdating = True


          If this is never set back to True, then it produces a situation like you've described.



          First search the code for the 'ScreenUpdating' property being set, remove it, and see if that fixes the issue.



          If you don't find 'ScreenUpdating' anywhere in the code, then you have some other problem.



          Edit: Looks like someone already mentioned screen updating in the comments above.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 31 '12 at 14:00









          ictathaictatha

          864




          864

























              0














              Thanks for this help.



              I was running a macro in development and live. I had no issue in DEV but it hung in live. It runs on a server rather than a local PC. I recall that when we first tried it in live we had to kill the task and it hung on subsequent retries. As soon as I added the lines
              application.screenupdating = TRUE
              doevents()
              doevents()



              immediately before
              application.screenupdating = FALSE



              the macro has worked as intended.






              share|improve this answer




























                0














                Thanks for this help.



                I was running a macro in development and live. I had no issue in DEV but it hung in live. It runs on a server rather than a local PC. I recall that when we first tried it in live we had to kill the task and it hung on subsequent retries. As soon as I added the lines
                application.screenupdating = TRUE
                doevents()
                doevents()



                immediately before
                application.screenupdating = FALSE



                the macro has worked as intended.






                share|improve this answer


























                  0












                  0








                  0







                  Thanks for this help.



                  I was running a macro in development and live. I had no issue in DEV but it hung in live. It runs on a server rather than a local PC. I recall that when we first tried it in live we had to kill the task and it hung on subsequent retries. As soon as I added the lines
                  application.screenupdating = TRUE
                  doevents()
                  doevents()



                  immediately before
                  application.screenupdating = FALSE



                  the macro has worked as intended.






                  share|improve this answer













                  Thanks for this help.



                  I was running a macro in development and live. I had no issue in DEV but it hung in live. It runs on a server rather than a local PC. I recall that when we first tried it in live we had to kill the task and it hung on subsequent retries. As soon as I added the lines
                  application.screenupdating = TRUE
                  doevents()
                  doevents()



                  immediately before
                  application.screenupdating = FALSE



                  the macro has worked as intended.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 1 '16 at 11:42









                  DJBDJB

                  1




                  1























                      0














                      In addition to the previous mentioned answers, If your excel sheet contains a fairly large amounts of data try saving it as an Excel Binary Worksbook (*.xlsb)



                      The binary format is a lot more faster than the standard xml format of excel. Hopefully your macros will be able to run faster too.






                      share|improve this answer
























                      • Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                        – DavidPostill
                        Nov 15 '16 at 11:57
















                      0














                      In addition to the previous mentioned answers, If your excel sheet contains a fairly large amounts of data try saving it as an Excel Binary Worksbook (*.xlsb)



                      The binary format is a lot more faster than the standard xml format of excel. Hopefully your macros will be able to run faster too.






                      share|improve this answer
























                      • Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                        – DavidPostill
                        Nov 15 '16 at 11:57














                      0












                      0








                      0







                      In addition to the previous mentioned answers, If your excel sheet contains a fairly large amounts of data try saving it as an Excel Binary Worksbook (*.xlsb)



                      The binary format is a lot more faster than the standard xml format of excel. Hopefully your macros will be able to run faster too.






                      share|improve this answer













                      In addition to the previous mentioned answers, If your excel sheet contains a fairly large amounts of data try saving it as an Excel Binary Worksbook (*.xlsb)



                      The binary format is a lot more faster than the standard xml format of excel. Hopefully your macros will be able to run faster too.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 15 '16 at 11:31









                      BKenBKen

                      516




                      516













                      • Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                        – DavidPostill
                        Nov 15 '16 at 11:57



















                      • Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                        – DavidPostill
                        Nov 15 '16 at 11:57

















                      Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                      – DavidPostill
                      Nov 15 '16 at 11:57





                      Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

                      – DavidPostill
                      Nov 15 '16 at 11:57


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f258259%2fmacros-in-excel-2010-hangs%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Сан-Квентин

                      8-я гвардейская общевойсковая армия

                      Алькесар