+ Reply to Thread
Results 1 to 11 of 11

Loop to CopyPaste and repeat iterations

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Loop to CopyPaste and repeat iterations

    Hi.

    I need loop to paste data range [A2:B56] and fisrt data range [D2:E2] on adjacent column and do it last cell in range [D:E]

    Ex:
    1. Copy range [A2:B56] sheet "Result" and copy range [D2:E2] on adjacent column
    2. Copy range [A2:B56] sheet "Result" and copy range [D3:E3] on adjacent column
    3. Copy range [A2:B56] sheet "Result" and copy range [D4:E4] on adjacent column
    4. Copy range [A2:B56] sheet "Result" and copy range [D5:E5] on adjacent column
    5. Copy range [A2:B56] sheet "Result" and copy range [D6:E6] on adjacent column
    And on and on.....2640 times.
    I try manual, but is large to write vba without loop.
    Please Login or Register  to view this content.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Loop to CopyPaste and repeat iterations

    See my file
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop to CopyPaste and repeat iterations

    My output is slightly different to yours. The last cell is 55, not 54.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop to CopyPaste and repeat iterations

    If you want the same output as the sample, change this line

    For ii = 2 To UBound(a, 1)

    INTO

    For ii = 2 To UBound(a, 1) - 1

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Loop to CopyPaste and repeat iterations

    Hi AB33
    I very happy for your help, thank you!!

    I have question...
    Attached Images Attached Images

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop to CopyPaste and repeat iterations

    Amended code works so long as there is no blank cell before the last row in column 5.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Loop to CopyPaste and repeat iterations

    Thank you very much!!!!!!!!!!!!!!!!!!!

  8. #8
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Loop to CopyPaste and repeat iterations

    Hi AB33
    I need you look more one time to my requeste, thank you!
    In column A and B (sheet "Result"), i have 32 rows (no blank rows in this range).
    In column D and E (sheet "Result"), i have 55 rows (no blank rows in this range).

    When code run, total rows in (sheet "Result"), It should be 1760 total rows.

    In my tests your code give me 1024 rows
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop to CopyPaste and repeat iterations

    Adjusted.
    If you want 1760, just use the minus I used in post 3 or 4.
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Loop to CopyPaste and repeat iterations

    Hi. I change sides data column A,B to column D,E
    I use o code and solve!
    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop to CopyPaste and repeat iterations

    That is another way of arranging the data
    You can now close the thread and mark it as solved.

+ 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 with several varibles, adding logic to skip iterations
    By edickman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2016, 05:18 PM
  2. [SOLVED] Loop is skipping iterations
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-22-2014, 06:50 AM
  3. [SOLVED] DropBox value triggering copypaste by "SEARCHING" for the correct cells to copypaste
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-03-2013, 09:41 AM
  4. [SOLVED] For loop iterations - quick question
    By drinkmorewine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2013, 02:51 PM
  5. [SOLVED] Losing format information in For Loop iterations
    By GFIJames in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2012, 11:17 AM
  6. VBA For loop where number of iterations can be changed from inside loop
    By barrboy89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2011, 12:18 PM
  7. [SOLVED] VBA | Individual Iterations faster than Loop Statement
    By Butaambala in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2005, 08:05 AM

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