+ Reply to Thread
Results 1 to 3 of 3

LOOP not functioning correctly

  1. #1
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    LOOP not functioning correctly

    The 2nd part of this code within the IF statement does not loop through. It starts with Sheets(“FrontEndApp”).Select. the first set which copies row 2 to row 1 works perfectly. after the copy and paste of the row I am trying to get it to print and then loop. Right now it is printing to pdf only once and then ending. But the copy and paste loop works perfectly. For eg if there are 20 values in A:A, only the first value will print to pdf but then all the values will loop through the copy and paste. This piece will perform the code and print in PDF form and then move onto the next. Any idea where in the above code I would need to place this for it to loop and print one by one in PDF form.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: LOOP not functioning correctly

    Hi,

    It's not entirely clear what you are trying to do. You've set a loop counter i but nowhere is this incremented. If you're trying to loop through a range of cells then the usual way is with a For..Next loop where the loop counter increments automatically when a Next is encountered.

    Can you clarify what you want to do. I'm guessing that you want to cycle through say 20 cells in column A and perform the Copy Paste Shift Up process.

    And as an aside, as a matter of good coding I'd be inclined to avoid a loop limit which is so large that if you ever inadvertently write some code that doesn't end when you expect, you will be left kicking your heels whilst the loop processes.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: LOOP not functioning correctly

    Hello:

    Yes I am definitely trying to to cycle through say 20 cells in column A and perform the Copy Paste Shift Up process. and when one cell shifts up, I want to run through the Print to PDF code and then loop through by moving up another cell and printing to PDF. Currently the Loop and shift up of the cells is working, however, the printing to pdf only prints the first cell and then does not print the rest. The counter was added because the loop was stopping halfway without it. I didnt know of any other way to prevent it from stopping halfway. I dont mind editing the code to eliminate the counter but just do not know how. I appreciate the help. Thanks

+ 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