+ Reply to Thread
Results 1 to 9 of 9

Slight modification to copy paste loop

  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Slight modification to copy paste loop

    The following code copies data entries in a loop on two seperate worksheets starting in row 5 and then skips every 5 rows to copy the next data entry. Can someone help me change the code to start in row 50 and then skip every 5 rows for the next entry?

    Please Login or Register  to view this content.
    Last edited by rhudgins; 10-19-2010 at 04:10 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Slight modification to copy paste loop

    I think you'd just change the line that says i = 6 to i = 51.
    Did that work?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Slight modification to copy paste loop

    That is incorrect. The following part of the code is what needs to be changed. The (5) at the end of the string says start in row 5 and then skip every 5 rows.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Slight modification to copy paste loop

    Sorry, I must've mis-interpreted your request. I am not familiar with that syntax (having a (5) at the end), someone else will have to step in.

  5. #5
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Slight modification to copy paste loop

    Here is a copy of my workbook..
    Attached Files Attached Files

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Slight modification to copy paste loop

    Oh, I got it. The 5 offsets the destination row by five. Cool, I never knew that option was available, I'd just had added 5 to the row.
    Anyway, it seems you are asking for the destination to start on row 50, then jump 5 each time. A quick fix would be:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Slight modification to copy paste loop

    That seems to work. Prior to asking you the question I was not sure what (Rows.Count, 26) was referring to. Can you provide me with a brief explanation?

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Slight modification to copy paste loop

    Sure. You have to look at the whole shtL.Cells(Rows.Count, 26).End(xlUp).Row
    This says start at the bottom of the shtL sheet. In column 26 (Z), go up from the bottom until you encounter a cell that has a value or formula. The .Row at the end indicates take the row number of that cell. So the whole thing together just finds the last row in Column Z that is being used.

    You can also start at the top with something like shtL.Cells(1, 26).End(xlDown).Row. This would find the first blank cell after row 1 and return the row number. Get it?

  9. #9
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Slight modification to copy paste loop

    This makes perfect sense. Thanks for help clarifying my question and helping me modify the macro!

+ 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