+ Reply to Thread
Results 1 to 3 of 3

Can't get loop to work correctly, skips rows after deletion

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Michigan
    MS-Off Ver
    Office 2010 Pro
    Posts
    12

    Can't get loop to work correctly, skips rows after deletion

    I'm having difficulties with deleting rows, I know why it's doing it (because the dewend range is being deleted) but I can't figure out how to correct it Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Can't get loop to work correctly, skips rows after deletion

    Hi,

    Your code is very long, so I haven't read it thoroughly. If this solution doesn't fix your problem, please upload your workbook so I can see the code working and breaking. Please also indicate what the result should look like and where the actual result is going wrong.

    When I have this problem, I find there's 2 solutions:
    1. Try looping through the rows in reverse order (if this is an option)
    2. When a row is deleted, decrement your incremental loop variable so that it repeats that same value.

    I hope this helps

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Can't get loop to work correctly, skips rows after deletion

    Hi, the generally acccepted method of looping when you are deleting rows is to start at the bottom and work up....
    Please Login or Register  to view this content.
    type syntax.

    Like ajryan88 I havent read the code to understand what the macro is trying to do but step -1 from the bottom is regarded as "best practice"

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

+ 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. [SOLVED] Loop Code skips rows eventhough it shouldn't
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2012, 08:58 AM
  2. IF function randomly skips rows - why?
    By Heirak in forum Excel General
    Replies: 3
    Last Post: 03-05-2012, 08:09 AM
  3. Rows Not Visible: Enumeration Skips
    By jefftanner in forum Excel General
    Replies: 2
    Last Post: 10-08-2008, 05:31 PM
  4. Counting number of rows (with skips)
    By MasterMonk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2007, 04:11 PM
  5. loop does not work correctly
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2006, 07:30 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