+ Reply to Thread
Results 1 to 12 of 12

Loop copy and paste

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Loop copy and paste

    I need a macro that copies range O1:O21 on sheet1 and then goes to sheet2 and checks to see if B2 is blank. If it is blank paste values into b2. If it is not then shift cells right and then paste values into b2. After it pastes the values, repeat the above 500 times. Possible?
    Last edited by ScabbyDog; 03-03-2013 at 01:38 PM.

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

    Re: Loop copy and paste

    Are you always pasting into B2?
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    Yes norie. Always b2, just the column will be shifted to the right so that b2 can be used for the new data.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,038

    Re: Loop copy and paste

    Hi Scabby Dog. I have de-activated the lines that will make the macro loop 500 times because I'm not sure if this is what you wanted. Have a look at the code and let me know if it suits your purpose.
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    I need it to paste special, values as sheet1 contains formulas which it is currently pasting with your code.

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    Another option would be, instead of shifting the column right, just paste the values into the next column that is empty in the range b2:zz22

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

    Re: Loop copy and paste

    Try this one

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    Doesnt work. It inserts an entire column rather than shifting the cells to the right and it only runs once and not 500 times.

  9. #9
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    I have this which works but doesn't paste values.

    Please Login or Register  to view this content.

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

    Re: Loop copy and paste

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Loop copy and paste

    Thanks Ab! We are close now. How would I add the loop to make it run 500 times now?

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

    Re: Loop copy and paste

    I am not sure which bit you want to repeat, but you can loop 500 times-500 rows

    Please Login or Register  to view this content.

+ 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