+ Reply to Thread
Results 1 to 10 of 10

Excel Choking on my Script

  1. #1
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Excel Choking on my Script

    Hello All,

    When I run this particular script with small values on one side of the equation it normally takes a lot longer to process than usual seeing as the right side of the equation has a 5th power in it. I recently switched from Excel 2007 where I codes this to Excel 2010 on my new computer, so if there is something hindering it with that change please let me know. The problem I am getting is that Excel stalls when I have a small value on the left and I get a "Run-time error 1004. Method 'Range' of object '_Worksheet' failed" error. I am assuming that reporting the values after every iteration the way it does is the culprit behind this, or just the sheer computing power. Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    It seems to be choking on this line of code:
    Please Login or Register  to view this content.
    Thank you all again for your help!

    DarkF1ame

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Excel Choking on my Script

    I'd guess, and it is only a guess, that because the starting value is small, each iteration is adjusted by a very small value, perhaps giving something like an exponential curve approaching the target very, very slowly.

    Perhaps you need to add a limit to the number of iterations ... on the basis that if you've gone through the loop a million times and it isn't getting much closer, that's gonna be close enough.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    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: Excel Choking on my Script

    Hi,

    What's the value of Abs(d_computed) when you get the error message?

    Are you able to upload the workbook here?
    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.

  4. #4
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Excel Choking on my Script

    Pipe_Calculator_Blank_Advanced.xlsm
    Attached is the workbook. The macros are password protected but I have already pasted the applicable sections above.

  5. #5
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Excel Choking on my Script

    Hello All,

    I still have yet to find a solution, does anyone know why this only happens in excel 2010 and not 2007?

    Thanks,

  6. #6
    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: Excel Choking on my Script

    Hi,

    Are 2010 and 2007 on the same PC? If not are there differences in the processor / ram?

    You need to definitively show that it's Excel software and not hardware and the only way is to run the process on the same machine with both 2007 & 2010. I'm not aware of any inherent differences between 2007 & 2010 in any of the areas your macro uses.

  7. #7
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Excel Choking on my Script

    I was running 2007 on a crappy laptop and I'm running 2010 on my new beastly tower. If there are any hardware changes they are all for the better. Thanks, I was thinking maybe the office suite had changed subtly. My 2007 machine will keep cycling through variables for as long as 10 minutes before freezing/crashing, and my new 2010 machine can't last more than 30 seconds. It seems odd. Thanks for the response though.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Excel Choking on my Script

    I'm testing your script on a 64 bit Windows 7, 32 bit Excel 2007 on a Sony Laptop.

    I've modified your code to put an exit counter into each loop (as I suggested earlier). For the sake of testing, each loop will drop out at 20,000 iterations. It produces Debug output every 1000 iterations.

    This is the amended code:

    Please Login or Register  to view this content.

    and this is the output in the Immediate Window:

    Please Login or Register  to view this content.

    As you can see, I get no output from the second loop and only one entry for the third loop. However, loops one and four go all the way ... and would, no doubt, go a lot further. In fact, I stopped the first loop after 30,000 iterations in early testing.

    I don't understand the calculations so I can't interpret the result. But, they are oscillating and, possibly, may never meet the exit criterion. Hence the reason for the "get out of jail" Exit Counter. This works but I really don't know if the results are then valid.

    See the amended workbook.

    Regards, TMS
    Attached Files Attached Files

  9. #9
    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: Excel Choking on my Script

    Quote Originally Posted by TMS View Post
    I'm testing your script on a 64 bit Windows 7, 32 bit Excel 2007 on a Sony Laptop.

    I've modified your code to put an exit counter into each loop (as I suggested earlier). For the sake of testing, each loop will drop out at 20,000 iterations. It produces Debug output every 1000 iterations.

    This is the amended code:


    Regards, TMS
    That's a nice analysis. I like it and the logical analysis that stems from it. Well done.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Excel Choking on my Script

    @Richard: thanks for the feedback and rep

+ 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. script to run the macro from Vb script with out opening the excel file
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2021, 03:33 AM
  2. calling the vb script from the shell script(unix platform)
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 06:21 AM
  3. Integrating Mainframe emulator script with excel's vba script
    By Himanshu Mishra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 10:30 AM
  4. Create VBA script to short, dedicated button in excel for script?
    By realized in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2009, 11:54 PM
  5. Script that edits the text printed on the button that runs the script
    By petalred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2008, 02:41 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