+ Reply to Thread
Results 1 to 4 of 4

Reducing the value of a loop counter

  1. #1
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Reducing the value of a loop counter

    Hey everyone,
    I've been trying to write a simple code that deleted every row with a blank cell in column "A", and I've attempted this using a For...Next loop as well as a Do Until loop (i'll post one example alone). I know I have to edit the value of "i" so that it changes if a row is deleted, but I keep getting into infinite loops and having to interrupt the code and I'm not sure why. Any ideas?
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Reducing the value of a loop counter

    Oops figured it out right after posting
    Had to decrease the value of the last row variable as well
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Reducing the value of a loop counter

    You need to start at the bottom and count down to 1

    Please Login or Register  to view this content.

    If you have a lot of rows then this will be extremely Slow.


    You should avoid using loops.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-08-2017 at 12:37 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Reducing the value of a loop counter

    Wow would never have thought of that thanks!

+ 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. Loop Macro with Counter
    By Ricky Wilko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2014, 07:33 AM
  2. For loop counter reset
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2014, 10:59 AM
  3. [SOLVED] Counter in a loop
    By jonathanrgz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2013, 05:46 PM
  4. loop counter not recognised
    By Dave H9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2011, 02:53 AM
  5. How can I avoid changing a loop counter within a loop?
    By broro183 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2009, 07:59 PM
  6. [SOLVED] Counter variable in For Loop
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2006, 02:00 PM
  7. trouble with counter in range loop
    By brya6347 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2005, 06:25 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