+ Reply to Thread
Results 1 to 6 of 6

Whats wrong with this loop

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Whats wrong with this loop

    I am realy puzzled by this loop I have to remove lines with zero amounts.

    This is the original loop:
    Please Login or Register  to view this content.
    However in file 1 it work ok but in the other file is leaves 2 lines behind.
    Of course I looked if there were decimals left, so like 10 or 20 positions but nothing.

    Then I tried this loop to see if it identified the correc lines with 0 :
    Please Login or Register  to view this content.
    And guess what....it identified exactly the lines which need to be deleted.
    But the original loop keeps skipping always the same 2 lines.

    Anybody a clue what could be up?
    Thanks.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Whats wrong with this loop

    Loop backwards.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Whats wrong with this loop

    And strangely enough that is how simple it can be....

    Thanks Norie!
    Is this one of excels unexplainable puzzles or is there some logic behind it why a loop forward does not work?

  4. #4
    Registered User
    Join Date
    09-29-2014
    Location
    KC
    MS-Off Ver
    2007
    Posts
    20

    Re: Whats wrong with this loop

    Please Login or Register  to view this content.
    http://www.ozgrid.com/VBA/VBACode.htm

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Whats wrong with this loop

    Thanks Coldday. Using a filter also would be an option indeed

  6. #6
    Registered User
    Join Date
    11-24-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    1

    Re: Whats wrong with this loop

    Forward loop doesn't work like that: you're removing rows, so your index doesn't match your current row.
    You can use the loop to count the rows left to be checked though

    counter loop <> index row

+ 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. Whats wrong with this code??
    By marksince1984 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2006, 08:18 AM
  2. whats wrong with if??
    By duncan79 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-31-2006, 05:20 PM
  3. [SOLVED] Whats wrong with this?
    By Metrazal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2006, 12:00 PM
  4. Whats wrong with this?
    By LucasBuck in forum Excel General
    Replies: 3
    Last Post: 01-12-2006, 04:15 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