+ Reply to Thread
Results 1 to 24 of 24

Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Hello,

    I am getting Intermittent error: "Excel has stopped working" while looping across all Spreadsheets even running in safe mode. It is pretty weird because it happens at some time frequently and suddenly it stops for some time. I am suspecting this issue is related to the loop code I am doing across all Spreadsheets. Can anybody help me to see if there is any issue on the below loop code that might cause this issue?

    When I run each Spreadsheet individually(without using the below code to loop), I DO NOT receive any error...


    Please Login or Register  to view this content.

    Does anybody have any better code to loop across all Spreadsheets like the way I am doing above?

    Thanks!
    Last edited by trizzo; 04-07-2015 at 03:04 PM.

  2. #2
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Sometimes I am getting: "Run-time error '9' - Subscript out of range in this part of above code:

    Please Login or Register  to view this content.

    Looks like it switches to the master Sub AllWorkbooks() and it does not find the Sub Startx which is in the other Spreadsheets where the loop is being made.
    Last edited by trizzo; 04-07-2015 at 04:20 PM.

  3. #3
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Maybe I am getting error: "Excel has stopped working" because I am not pausing(waiting) for the next Spreadsheet. I have noticed that every time the loop ends(about to start the next spreadsheet) I receive the error. Not sure, hard to find out.

  4. #4
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    In fact, I just tried to apply an application wait of 5 seconds, but the issue still persists, still getting "Excel has stopped working".

  5. #5
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Can anyone help me please?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    What does the macro Startx do?
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    The Startx macro updates several worksheets, makes a SQL Query, brings data to the worksheets and insert some formulas to make summary of data brought by SQL, but, it has worked perfectly running individually, it never issued any error....
    I have found that the issue happens whenever the Startx macros ends and then this master one(AllWorkbooks) tries to save the Workbook of Startx macro, and then the Excel stops working....I am almost sure the issue is in this middle:

    Please Login or Register  to view this content.
    Last edited by trizzo; 04-08-2015 at 10:04 AM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Do all the workbooks have the Startx macro?

    Is it the same code for each workbook?

  9. #9
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Yes, all the workbooks are exactly the same code. Unfortunately, I am not sure if I can share here because it is confidential, but as I said, I did not see any issue on them, every time I run them individually there are no issues, and I run them many times a day... but when I use this macro(AllWorkbooks) to loop through them, I get the message: "The Excel has stopped working", and this happens right after the Startx macro ends and the AllWorkbooks macro tries to save it and go to the next workbook to start the Startx macro all over again.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Have you considered running the Startx code from the workbook the AllWorkbooks code is in?

  11. #11
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Maybe if I use the save Workbook command on each Workbook where Startx is hosted would help?

    If I remove this part from AllWorkbooks macro:
    Please Login or Register  to view this content.
    And I put the save command on each Startx, the AllWorkbooks macro stops the loop through workbooks. That is weird!

  12. #12
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Hey Norie, I did not try to use AllWorkbooks macro where Startx is stored. It should be a good option! Let me try.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    What I'm suggesting is you move the Startx macro to the same workbook as AllWorkbooks.

    Then when you open each workbook you run Startx from the workbook AllWorkbooks is in on the workbook you've just opened.

  14. #14
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    ahhhh ok Trying... Just a moment...

  15. #15
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    In fact, the Startx macro, calls other several macros which are currently stored in Startx workbook... Do you think I need to move all of them or just the Startx macro?

  16. #16
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    I tried to put the all the Startx macros in AllWorkbooks workbook, it worked doing a loop for the first workbook(completed successfully), but it does go to open the next workbook. That is weird!!

  17. #17
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Here is what I did to call Startx in AllWorbooks workbook:


    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Any idea why the next workbook is not going through now?

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    I was suggesting have one Startx in the AllWorkbooks workbook.

  20. #20
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Sure, I am going try that. But as Startx calls other several modules, I would need to call all of them by using the following:

    Application.Run ("'" & MyFile & "'!Module1")
    Application.Run ("'" & MyFile & "'!Module2")
    and so forth....

    I am going to try that and I will let you aware. Thanks!

  21. #21
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Hey Norie,

    Thanks for all your suggestions!
    I think I found where the issue is! Looks like after Selection / Number.Format in one of the modules is causing that.
    I removed all the Number.Formats and I am testing. So far, after 10 runs I did not receive any error: "Excel has stopped working..."

    I will you let aware if all goes well.
    Last edited by trizzo; 04-09-2015 at 07:27 AM.

  22. #22
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Norie, my issue is solved. I removed the NumberFormats of the modules, I will need to review to apply them correctly. Thanks a lot for your help and patience!

  23. #23
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Can you post an example of one of your Startx macros?

    I've go a feeling that they could be tidied up a bit.

  24. #24
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Intermittent error: "Excel has stopped working" while looping across all Spreadsheets

    Here it is:

    Please Login or Register  to view this content.
    Last edited by trizzo; 04-09-2015 at 04:05 PM.

+ 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. Replies: 7
    Last Post: 11-14-2013, 04:25 PM
  2. Replies: 2
    Last Post: 06-10-2013, 06:18 PM
  3. Replies: 2
    Last Post: 10-22-2012, 09:55 AM
  4. Replies: 2
    Last Post: 10-02-2012, 12:17 PM
  5. "Excel has stopped working" message poping up
    By RBlodgett in forum Excel General
    Replies: 3
    Last Post: 05-21-2012, 04:25 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