Closed Thread
Results 1 to 4 of 4

Can't get my loop to stop!!

  1. #1
    Registered User
    Join Date
    07-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Can't get my loop to stop!!

    I have written a loop to go down a range of codes one by one, copying and pasting each active cell into another worksheet, printing that worksheet and repeating the process for the next code down in the list theoretically until the bottom cell which contains the word END, where I want my macro to stop.

    Despite my variable being assigned and in VBA showing that it recognises the value to be "END" when the active cell reaches the bottom cell the macro is not stopping and carries on going into the blank cells.

    Can anybody see where I've gone wrong? As far as I can see I've assigned the variables and given a condition for the loop to stop and am at a loss to why the thing keeps going once it reached the "END" cell.

    Code below, any advice or thoughts greatly appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Can't get my loop to stop!!

    You only assign a value to myCommand at the start of the procedure, so its value is never 'END'. You need to move the myCommand = Activecell.value line within the loop in order to update the variable.
    Cross-posted here, BTW.
    Last edited by romperstomper; 07-30-2009 at 08:09 AM. Reason: Added cross-post
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Can't get my loop to stop!!

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!
    http://www.mrexcel.com/forum/showthread.php?t=406319

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Can't get my loop to stop!!

    Your thread is being closed for non compliance with our rules. Please PM me when you have read the forum rules RULES and made the changes to your post accordingly, i will then unlock your post so you may continue with the thread!

    Post Closed

Closed 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