+ Reply to Thread
Results 1 to 6 of 6

The custom sort list causes my excel to crash after running and then trying to save

  1. #1
    Registered User
    Join Date
    03-22-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    9

    The custom sort list causes my excel to crash after running and then trying to save

    Hi all,

    I have the following custom sort code that I am using to sort column A on the exposure tab. I saw someone else online with a similar request of my own and modified the code online to my personal needs. The sort code works exactly like I would expect it to, but after running the macro for the code below and subsequently trying to save the workbook the workbook crashes and excel is unable to recover the file. No matter what I do it will not allow me to save my workbook after using the below code. Would anyone have any suggestions on how I could clean up the code and/or use an alternate method so I would not have the crashing issue?

    Thanks,

    Jon

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    05-04-2012
    Location
    Stamford,Connecticut,USA
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: The custom sort list causes my excel to crash after running and then trying to save

    Try adding the save command at the end of your sub.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    Atlanta
    MS-Off Ver
    Office 2010/365
    Posts
    3

    Re: The custom sort list causes my excel to crash after running and then trying to save

    I'm having the same problem - it only seems to happen when a custom sort order is involved - it happens whether I use the range.sort method or sortField.add. The save command at the end of the sub only automates the crashing.

  4. #4
    Registered User
    Join Date
    09-19-2012
    Location
    Atlanta
    MS-Off Ver
    Office 2010/365
    Posts
    3

    Re: The custom sort list causes my excel to crash after running and then trying to save

    Ok - it turns out that deleting the custom list was the source of my problem (whether with VBA or manually) and clearing the sortFields (ActiveSheet.Sort.SortFields.Clear) right before calling the DeleteCustomList method fixed this for me.

  5. #5
    Registered User
    Join Date
    10-20-2006
    Posts
    1

    Re: The custom sort list causes my excel to crash after running and then trying to save

    Quote Originally Posted by stuartho View Post
    Ok - it turns out that deleting the custom list was the source of my problem (whether with VBA or manually) and clearing the sortFields (ActiveSheet.Sort.SortFields.Clear) right before calling the DeleteCustomList method fixed this for me.
    Thanks for the Tip!

  6. #6
    Registered User
    Join Date
    03-12-2022
    Location
    canada
    MS-Off Ver
    365
    Posts
    1

    Re: The custom sort list causes my excel to crash after running and then trying to save

    This answer is over 10 years old and it is gold!!! I have been having this issue for 3 days now and managed to narrow it down to one line of code. NOWHERE on the internet is this explicitly defined to add the .clear line in the script. Many many thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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