+ Reply to Thread
Results 1 to 6 of 6

Infinite Loop

  1. #1
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    Infinite Loop

    Towards the bottom I highlighted the code that I believe is giving me the problem. I want to ask the user two questions to make sure everything worked correctly. IE the printer was on when the macro was ran would be an example of something not going correctly, because if they click yes to both questions then the original data that the macro modified will be deleted. But if the user clicks yes on both of the questions the code that is supposed to run does, but then it just hangs.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    Re: Infinite Loop

    No one has any ideas?

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Infinite Loop

    It is really hard to work out what you are doing here, but here is my feedback

    Please Login or Register  to view this content.
    The line above looks problematic to me for a number of reasons.
    Firstly it is an If/Then statement, but you are not giving the user any opportunity to say "it's not OK". So no matter what happens, it is going to pass this test.
    Secondly, you have a Goto after the THEN statement. This is not required, nor is the Continue: line marker. It will automatically enter the loop if the test passes.

    Then this next line of code looks like a problem too for similar reasons

    Please Login or Register  to view this content.
    You should structure your If/then statements like this.

    Please Login or Register  to view this content.
    See if that solves your problem

  4. #4
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    Re: Infinite Loop

    Thanks, I will try it tomorrow and let you know if it works!

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Infinite Loop

    A lot of recorded code, edit out all the stuff it records that you know you don't need...for instance if you add a box around a cell, you only need the 4 lines of code that put the left/right/top/bottom on the cell, all the rest is dross.

    Compare this to your original to see how much reduction in your code is possible by removing the dross and merging multiple lines of "selecting" into one line of direct command.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    Re: Infinite Loop

    Thanks JB, yeah I'm not very good at writing code, I still have to record most of what I know, I've picked up a few things from the peeps here and will look over what you've done. Thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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