+ Reply to Thread
Results 1 to 5 of 5

Copy Worksheet to the end of another Worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50

    Copy Worksheet to the end of another Worksheet

    I would like to implement a macro that will copy the contents of the active worksheet (sheet1 for example) and will paste it to the end (the first empty row) of another worksheet (sheet2) both sheets are in the same workbook, and sheet2 has pre-existing data.

    Additional Info: if need be, Columns A to H have continuous data (no empty cells till the end of the database) and column I has some empty cells.
    Last edited by opg; 08-14-2009 at 11:23 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Worksheet to the end of another Worksheet

    Try these lines of code:

    Dim LR as Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    Range("A1:I" & LR).Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50

    Re: Copy Worksheet to the end of another Worksheet

    thanks, it does the trick, even with an auto-filtered query
    Last edited by opg; 07-31-2009 at 02:06 PM.

  4. #4
    Registered User
    Join Date
    07-11-2008
    Location
    Toronto
    Posts
    50

    Re: Copy Worksheet to the end of another Worksheet

    How can I modify the
    A2:J
    in the code below to always copy the active range starting from the second row if it's not always A2 (for example if I use an Autofilter query, A2" might become A4 because the autofilter is applied I would like to add an offset

    Sub copytoSheet9WS2()
    
    Dim LR As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    Range("A2:J" & LR).Copy Sheets("Sheet9").Range("A" & Rows.Count).End(xlUp).Offset(0, 0)
    
    End Sub
    Last edited by opg; 08-14-2009 at 11:45 AM.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Worksheet to the end of another Worksheet

    You don't need to. If the range is Filtered, the only thing that gets copied is the visible rows, right?

+ 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