+ Reply to Thread
Results 1 to 14 of 14

Macro worked, but now crashes my workbook.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Macro worked, but now crashes my workbook.

    Had a macro built with this sites help and it worked perfectly. Until shortly ago. I haven't adjusted the code at all other than the name. The only thing i've done since working was share the workbook and lock it, but I have since unlocked it and unshared it.

    Macro is as follows:

    Please Login or Register  to view this content.
    When I 'step into' the macro it breaks when I am on the ".Range("A4", "XFD1000000").ClearContents' and hit F8. That is when I get the spinning wheel.
    Last edited by taylorsm; 01-27-2017 at 11:10 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro worked, but now crashes my workbook.

    I've never seen anyone actually use the last XFD column so that's a first!

    My first thought is that whilst the original workbook was created with an Excel version > 2007 when the 16K columns were first introduced it has now been opened with a version of Excel prior to that which only has 256 columns. i.e. an .xls file

    Why not change that line to

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro worked, but now crashes my workbook.

    Hello taylorsm,

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    That is a massive amount of Cells to run trough for any System!

    Besides that, it will definitely crush on any System Running on Any Excel version prior to Excel 2007.

    At best, please try the Code below. Maybe it will speed things up a bit.

    Please Login or Register  to view this content.
    Regards,
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Macro worked, but now crashes my workbook.

    Building on Richard's and Winons replies:

    if you replace the .clear contents line with:
    Please Login or Register  to view this content.
    It will do only as much work as there is to do.

    Also if you put in the

    Please Login or Register  to view this content.
    remember to undo it afterwards:

    Please Login or Register  to view this content.


    click on the * Add Reputation if this was useful or entertaining.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro worked, but now crashes my workbook.

    Quote Originally Posted by tony h View Post
    Building on Richard's and Winons replies:

    if you replace the .clear contents line with:
    Please Login or Register  to view this content.
    Neat. An excellent suggestion

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro worked, but now crashes my workbook.

    Do you mean replace
    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.


    I tried this and it seems to work...

    Please Login or Register  to view this content.
    Last edited by taylorsm; 01-27-2017 at 12:51 PM.

  7. #7
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro worked, but now crashes my workbook.

    I also noticed the XFD1000000 lines, but I know nothing of Macro to question someone else that wrote the thing, you know?

    Winon, it still crashed with yours.

  8. #8
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Macro worked, but now crashes my workbook.

    You said it crashed. Does it come up with an error message? Or are you, as before, getting the spinning wheel?


    Also when you reply could you
    1. report what happens if you change the line to
    Please Login or Register  to view this content.
    It won't clear the whole area but it would just check a few things.
    2. report how big the file is and whether it seems over large. I suspect that the run of the code previously may have swollen the file which would cause the .usedrange to run slowly as well.

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro worked, but now crashes my workbook.

    I think i got it working with the macro I put in the 10:42 post i edited. Thanks!

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro worked, but now crashes my workbook.

    Hello taylorsm,

    ...the 10:42 post...
    It is actually better to quote by Post Number, to avoid time differences across the Globe.

    Regards.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro worked, but now crashes my workbook.

    Hi taylorsm,

    Glad you finally managed to get your issue resolved.

    Thank you so much for the "Rep"!

    Regards

  12. #12
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro worked, but now crashes my workbook.

    Ah, yes!

    Post #6 if any future visitors are wondering.

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro worked, but now crashes my workbook.

    That's it, my man!!!

  14. #14
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Macro worked, but now crashes my workbook.

    I am glad it worked for you just a couple of suggestions: one cosmetic and one functional

    Please Login or Register  to view this content.
    with this:
    Notes:
    1. the cosmetic element is changing the position of some of the code
    2. the functional is to ensure that the code uses the named sheet Result. This could be done by changing ActiveSheet to Sheets("Result") or as I have here by letting the .UsedRange pick up the sheet from the with clause.

    Please Login or Register  to view this content.

+ 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 2007 : Excel Crashes when I re-calculate (F9) Workbook
    By lissa.lourdes in forum Excel General
    Replies: 1
    Last Post: 02-25-2011, 08:41 PM
  2. Excel crashes when macro gets workbook to close
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2011, 09:50 AM
  3. Workbook crashes excel when a macro is performed.
    By Phixtit in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-05-2010, 03:55 AM
  4. Excel Crashes when saving workbook...
    By Stu M in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2009, 11:07 AM
  5. Excel Workbook crashes
    By cmourati in forum Excel General
    Replies: 3
    Last Post: 12-03-2006, 06:42 PM
  6. [SOLVED] Macro crashes "Automation error" during copy of workbook with char
    By Yorch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2006, 05:10 PM
  7. [SOLVED] Workbook Crashes Excel
    By Val Mehling in forum Excel General
    Replies: 4
    Last Post: 01-22-2005, 03:08 AM

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