+ Reply to Thread
Results 1 to 6 of 6

Do While ....Loop Never Stops

  1. #1
    Registered User
    Join Date
    03-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    90

    Do While ....Loop Never Stops

    I used this loop on another spreadsheet and just reused it on a new one but the loop gets stuck and keeps running. What do you see wrong with this Do While....Loop?

    HTML Code: 
    Last edited by jadown; 07-17-2013 at 09:29 AM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Do While ....Loop Never Stops

    Isn't that code basically used to delete all rows below A1? Instead of a loop, why not just have a simple range.clear?
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    03-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    90

    Re: Do While ....Loop Never Stops

    tigeravatar,

    The sheet has multiple lines through the sheet that has the column titles throughout the sheet which has a empty row before them and after them. So I used a similar loop on another sheet to do the same thing and it worked. But on this new sheet I modified the macro a little and it deleted everything on the sheet.

    I will give your suggestion a try to see if it works. Thanks for the help.

  4. #4
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Do While ....Loop Never Stops

    Lemme try to clear..

    You cant delete No Of Rows.. It will always be 65536 (yes I know.. 2^20 also).. so whenever, you are re-checking .. on next step.. i will still be 65536.
    So obviously loop will run forever..

    Try This.

    Please Login or Register  to view this content.
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Do While ....Loop Never Stops

    your problem:
    1 only if A2 is empty or column A is fully populated will Range("A1").End(xlDown).Row reach the last row and your loop will exit
    2 if A2 is not empty, you find the next blank row and delete 4 rows then repeat but then option 1 can never be true and your loop cannot exit
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Registered User
    Join Date
    03-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    90

    Re: Do While ....Loop Never Stops

    Josie & Debraj,

    Thanks for your help. It works now.
    I think I understand your code Debra. I'll have to look at it a couple more times to understand how you came up with it because I would've never thought of that.
    Thanks again!

+ 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. VBA - Loop stops too soon
    By DavidBW in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2013, 06:42 AM
  2. loop that stops when certain value is obtained
    By ukhan12 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2013, 10:41 PM
  3. [SOLVED] A Loop does not loop throught. It stops after two cells.
    By AB33 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-14-2012, 01:14 PM
  4. Code Stops in a loop?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2011, 01:57 PM
  5. For Loop STOPS at Random Iteration!
    By wjoc1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2007, 09:58 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