+ Reply to Thread
Results 1 to 18 of 18

Paste Range to next available sheet

  1. #1
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Paste Range to next available sheet

    Please see the attached file.

    I need a macro that will copy range A1:C1 of sheet 3 and paste it to A1 of the next available sheet.

    On the attached file, you will notice that sheet 1 has something in Cell A1:C1, so in this case I would need it to paste A1:C1 of sheet 3 to Cell A1:C1 of sheet 2 (Since it is the next available sheet without data in that range)

    It has to work for as many sheets as are in the workbook.

    Thanks
    Attached Files Attached Files
    Last edited by jbmerrel; 05-23-2012 at 04:38 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    I might be able to give this a go...

    Is there going to be some type of order that the sheets are in?

    Are there going to be any sheets that should be excluded (outside of a sheet that alreay has numbers)?

    Are you going to run this macro from the activesheet with data you want moved?

    Will you ever run out of sheets tabs or is it possible every tab is filled but not more tabs in the workbook?
    HTH
    Regards, Jeff

  3. #3
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Paste Range to next available sheet

    does this only need to work from sheet3, or would you like to copy from any active sheet?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    Maybe this could be a start...

    Run from the activesheet

    Please Login or Register  to view this content.

  5. #5
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Paste Range to next available sheet

    works from the active sheet i think:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    Sorry it took me so long. Let me test these and I'll get back with you.

  7. #7
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    This Pastes it to A1 of the active worksheet

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    What does and what did you do?

  9. #9
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    Neither of the two codes work. I wish I could help you debug but I am a VBA NOOB

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    With the worksheet you posted and the code from post #4, Sheet3 is active >> alt + F8 >> run movedata >> A1:C1 from sheet3 is moved over to sheet2 because it is empty in A1.

  11. #11
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    The First Code is VERY close. It does paste it to the correct place, but also on the active worksheet

  12. #12
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    It doesn't paste it to the activesheet, it just copies it, but you want it completely cut?

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    I would like for it to copy and paste (Values Only). This code copies it to the next page AND every subsequent sheet after it as well. I have 6 sheets. Sheet 6 is an import from a database. Sheets 1-5 are for something else. It needs to copy the imported data on the next available sheet and then stop. Right now it is putting it on sheet1 and sheets 2-5 as well. It needs to just stop after it has pasted the info once.

    Thanks Again for taking the time to help me!

  14. #14
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Paste Range to next available sheet

    Give this a try

    Please Login or Register  to view this content.

  15. #15
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Paste Range to next available sheet

    jbmerrel,

    One way...
    Please Login or Register  to view this content.
    Last edited by tigeravatar; 05-22-2012 at 06:35 PM. Reason: Updated code to include "cut" option
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  16. #16
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    Just found out the source range and destination range will be changing. Can we make this so that I can select a range from the source page and have it copy ONLY THE VALUES to the next available worksheet. The above code is pretty close to what I need.

    Thanks Again, I really appreciate everybody!!!

  17. #17
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Paste Range to next available sheet

    Updated code. It still places the values in A1 of the destination worksheet, but it places the values into the same size range as the selected range from the source worksheet. So if the selected range was C5:E6 (2 rows and 3 columns), the values will be placed in the destination worksheet A1:C2
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    12-14-2010
    Location
    Texas,United Stated
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Paste Range to next available sheet

    You are the man!!!!!!!!!!!!!!!!!!!!!

    Thank you very much for your time and effort!!!!!!!!!!

    Jbmerrel

+ 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