+ Reply to Thread
Results 1 to 5 of 5

Add to the loop length in a For/Next

  1. #1
    Registered User
    Join Date
    01-21-2014
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Add to the loop length in a For/Next

    I have a for next loop that uses the number of parent parts (last row in a column) to determine how many times to loop.

    When I paste stuff into the parent column I am adding the number of items I added to the number of parent parts. However, it still only runs until the original number has been met.

    How should I be doing this?

    Please Login or Register  to view this content.
    Download the attachment for details. It should insert child parts based on their parent part number.
    Attached Files Attached Files

  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: Add to the loop length in a For/Next

    You can't change the 'length' of a For Next loop within the loop.

    What is it you are trying to do with your code?

    Perhaps you need another type of loop, or even a loop within a loop.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-21-2014
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Add to the loop length in a For/Next

    The original column length dictates the amount of loops. When rows get inserted into the table, the column length grows. Therefore, my code ends prematurely.

  4. #4
    Registered User
    Join Date
    01-21-2014
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Add to the loop length in a For/Next

    Looks like a Do While is the ticket.

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

    Re: Add to the loop length in a For/Next

    Try looping from the bottom up.

+ 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] Shorten string length if exceeds 31 characters (max sheet name length)
    By r2fro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 05:57 AM
  2. Repeat Calculation At Length & Calculate Lowest Value At Length
    By sanju2323 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-17-2013, 09:19 AM
  3. [SOLVED] Cell length VBA to add trailing characters until a specified length is reached
    By bkeller83 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-24-2013, 10:43 PM
  4. Create a loop by defining X as integer, to shorten length of code
    By ahmerjaved in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2013, 01:11 PM
  5. Adding length to For Next loop after starting
    By alcarl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2012, 02:41 PM

Tags for this Thread

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