+ Reply to Thread
Results 1 to 10 of 10

Deleting tabs has a tendency to make Excel crash

  1. #1
    Registered User
    Join Date
    09-11-2017
    Location
    USA
    MS-Off Ver
    Excel for Mac 2016
    Posts
    10

    Deleting tabs has a tendency to make Excel crash

    There are a couple spots in the workbook I built where I want to delete one or more tabs. The first scenario I used was an extremely complicated one where the delete command occurred at the end of a large amount of code, so I assumed that was the reason Excel got confused and crashed.

    However, I am also seeing this in a much simpler scenario. Essentially I have two tabs in my workbook which are used for demo purposes only (to introduce the workbook functionality). When I'm done, I want to click a button that says "End Demo" which will then delete the two demo tabs. I have researched this extensively and tried implementing some of the solutions I've discovered, but none have helped. Here is the code the button calls:
    Please Login or Register  to view this content.
    I cut the button that called the code so it didn't get hung up on trying to call that object on a deleted tab. I introduced a brief wait to allow the system to catch up. And I activated a different workbook tab so it wasn't deleting the active sheet. Still I get the crash more often than not. What else can I try to allow these tabs to delete without crashing?

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Deleting tabs has a tendency to make Excel crash

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.



    To add a file to a post

  3. #3
    Registered User
    Join Date
    09-11-2017
    Location
    USA
    MS-Off Ver
    Excel for Mac 2016
    Posts
    10

    Re: Deleting tabs has a tendency to make Excel crash

    See attached
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Deleting tabs has a tendency to make Excel crash

    I think your problem is that the Button11_click event is in one of the worksheets you are deleting. If you move the button to the first worksheet that you are not going to delete, it works fine.

  5. #5
    Registered User
    Join Date
    09-11-2017
    Location
    USA
    MS-Off Ver
    Excel for Mac 2016
    Posts
    10
    Quote Originally Posted by EssoExplJoe View Post
    I think your problem is that the Button11_click event is in one of the worksheets you are deleting. If you move the button to the first worksheet that you are not going to delete, it works fine.
    Unfortunately I need the button to be on the page that is being deleted. This is true in the other example I alluded to in my first post. That's why I was trying to cut the button object before deleting. Do you have any other workarounds?

  6. #6
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Deleting tabs has a tendency to make Excel crash

    You might be able to have the button11 trigger an event on the main sheet then delete the sheets from there. For example, you could set a cell (maybe A1) to a code like 99999. In the main sheet cell change event, delete the two sheets if the target in the sheet change event was cell a1 and the value 99999. Then reset cell A1 to whatever. This might do it.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Deleting tabs has a tendency to make Excel crash

    I cannot reproduce the crash in in 2010 but would suggest that you use OnTime in order to allow the button click code to finish before deleting the button or its sheet
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Deleting tabs has a tendency to make Excel crash

    Do you have many formulas in the original workbook?

  9. #9
    Registered User
    Join Date
    09-11-2017
    Location
    USA
    MS-Off Ver
    Excel for Mac 2016
    Posts
    10

    Re: Deleting tabs has a tendency to make Excel crash

    Quote Originally Posted by xlnitwit View Post
    I cannot reproduce the crash in in 2010 but would suggest that you use OnTime in order to allow the button click code to finish before deleting the button or its sheet
    Please Login or Register  to view this content.
    This worked perfectly, thanks so much!

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Deleting tabs has a tendency to make Excel crash

    You're welcome. Please remember to mark the thread Solved.

+ 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 Crash when deleting sheet after i run VBA
    By lexusap in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-03-2017, 08:32 PM
  2. Replies: 2
    Last Post: 03-16-2017, 02:42 PM
  3. [SOLVED] Central tendency formulas that disregard specific values before giving a result
    By TnD_Guy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-15-2015, 01:45 PM
  4. Replies: 1
    Last Post: 03-27-2014, 09:43 AM
  5. Problems Deleting Tabs in Excel 2007 Workbook
    By fedrer in forum Excel General
    Replies: 1
    Last Post: 07-15-2009, 12:35 PM
  6. [SOLVED] Can I make a graph using several tabs in an excel spreadsheet
    By Sheila in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-23-2006, 11:45 PM
  7. Deleting tabs in Excel
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2005, 03:06 PM

Tags for this Thread

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