+ Reply to Thread
Results 1 to 5 of 5

Do Until Loop not working

  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    Washington DC
    MS-Off Ver
    2013
    Posts
    34

    Do Until Loop not working

    Here is my code. It is getting errors that I don't understand. It will run through the loop various times and delete a chunk of rows like it's supposed to but then it will thow up different errors. its crazy. It works when I F8 through the whole thing but when I run it it always hits a snag and the debugger sometimes yellows out the "Loop" line and sometimes the "ActiveCell.Offset(-1, 0).Select" line and sometimes the "Cells(Rows.Count, 9).End(xlUp).Select" Line. I don't understand what is wrong with any of the code. It worked perfectly yesterday but I changed the query that is the source data and the test column is the 9th column and not the 11th. Any help would be appreciated. I have a data sheet with 1500 records for 7 different accounts and I want to write this code to make a separate worksheet for each account.
    Please Login or Register  to view this content.
    Last edited by wellen72; 06-08-2016 at 04:02 PM.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Do Until Loop not working

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    I can see you tried to put tags on, so I'll tell you this for now until you fix the tags:
    1. Most likely the problem is with your .Select. If the row is deleted, you don't want to Select -1 row. But....
    2. Don't use ActiveCell and Select. VBA doesn't need to activate or select cells; that's a human activity
    3. The better/faster approach would be to filter on your two conditions, delete the visible cells, then remove the filter.


    I'd be happy to help you with the last point
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Registered User
    Join Date
    11-12-2015
    Location
    Washington DC
    MS-Off Ver
    2013
    Posts
    34

    Re: Do Until Loop not working

    Thanks, I didn't see a # symbol at the top of the post window when I tried to edit. I'd love to know how to write the coded to do what you describe in #3. When you have time I'd appreciate it.

    Cheers,

    Chuck

  4. #4
    Registered User
    Join Date
    11-12-2015
    Location
    Washington DC
    MS-Off Ver
    2013
    Posts
    34

    Re: Do Until Loop not working

    Please Login or Register  to view this content.
    I hope this fixes it. I still don't see a # symbol anywhere.

    Cheers,

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Do Until Loop not working

    Another approach:

    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. For Next Loop not Working
    By basmster in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-01-2016, 01:11 PM
  2. [SOLVED] Do Until Loop Not Working
    By jjl287 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2015, 04:49 PM
  3. For loop within loop not working correctly
    By HalPlz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2015, 12:06 AM
  4. [SOLVED] For Next Loop not working
    By jacob@thepenpoint in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2013, 02:24 PM
  5. Loop not working...
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2011, 08:12 AM
  6. [SOLVED] Why is this Do Loop not working right?
    By evilrtc in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-21-2007, 01:52 AM
  7. [SOLVED] Do...Loop not working
    By Sunny Lin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2005, 09:06 PM

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