+ Reply to Thread
Results 1 to 7 of 7

Do until Loop not ending

  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Do until Loop not ending

    I am trying to write a macro at work that separates a list of part numbers with semi-colons and in groups of 22. I wrote 2 separate macros, 1 for each process and it works fine. Then I decided to combine them and and have the second half loop until the end of the document. The issue I'm having is that the loop never ends, it just keeps adding a line in between the groups of 22. Here is an example of what the beginning document looks like.

    Part No
    16516541
    1651764
    65174651
    61567867
    56419874
    16541674
    ... and so on

    The list always starts with "Part No" and then the list of numbers could be as short as 10 or as long as 2000. The finished document needs to have groups like this:

    Part No;654981;6541687;54867;6354357;354863754;... and so on until there is 22 numbers then a new line then the next group of 22, until all of the part numbers are are separated into groups. Here is the code I have so far.

    Please Login or Register  to view this content.
    Moderators Note: Please follow Forum Rule #3 and use code tags. Added this time, but please use them in the future…Thanks.
    Last edited by jeffreybrown; 12-27-2012 at 11:31 AM.

  2. #2
    Registered User
    Join Date
    12-19-2012
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Do until Loop not ending

    UPDATE:
    Here is a new code I used and it works. I just need to add in a second line in between the groups and I will be done.

    Please Login or Register  to view this content.
    Last edited by Alexm963; 12-27-2012 at 01:42 PM.

  3. #3
    Registered User
    Join Date
    12-19-2012
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Do until Loop not ending

    Nevermind no issues now. Here is the final code.

    Please Login or Register  to view this content.
    Last edited by Alexm963; 12-27-2012 at 01:42 PM.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Do until Loop not ending

    Much more efficient (and simpler):
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Registered User
    Join Date
    12-19-2012
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Do until Loop not ending

    Awesome! Thanks. I will give that a try at work tomorrow.

  6. #6
    Registered User
    Join Date
    12-19-2012
    Location
    Spokane, WA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Do until Loop not ending

    I tried that one just now. On a short list it worked fine, but on one with 1500 P/N's it crashed word on my system.

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Do until Loop not ending

    Before posting, I tested it on a document with 10,000 P/Ns and it ran fine, taking much less time than your's took for the same job.
    Last edited by macropod; 12-29-2012 at 10:06 PM. Reason: added timing info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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