+ Reply to Thread
Results 1 to 12 of 12

Macro to merge 2 sheets to one and keep header row

  1. #1
    Registered User
    Join Date
    01-05-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Macro to merge 2 sheets to one and keep header row

    I have sheets named PO_1 and PO_2 with the same number of columns and header names. The number of rows changes each day from a query refresh.
    I want to copy the rows (A2:F2 down to last row) from each of these sheets to a sheet named "Totals" which already has the header row

    I have read through many posts on this problem and tried about 10 different macros but I was not able to get any of them to work for me so I had to ask the question.

  2. #2
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Macro to merge 2 sheets to one and keep header row

    Hi, I'd say you'd need to try something like:

    Please Login or Register  to view this content.
    If my answer helped pls click the star =)

  3. #3
    Registered User
    Join Date
    01-05-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to merge 2 sheets to one and keep header row

    I am getting an error on this line
    ActiveCell.Offset(1, 0).Select 'will go one cell down, to the first blank cell

    it is going down to A65536 on Totals sheet

  4. #4
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Macro to merge 2 sheets to one and keep header row

    Ah, I'm assuming there is currently no data in the totals spreadsheet?

    If this is the case take out the first

    Please Login or Register  to view this content.
    so you are left with

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Macro to merge 2 sheets to one and keep header row

    or saying that you could just change it around so it works the other way which would be like this

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Macro to merge 2 sheets to one and keep header row

    try
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Macro to merge 2 sheets to one and keep header row

    Hi Carcel,

    Based on this recent post by me for A.Patel, try this:

    Please Login or Register  to view this content.
    HTH

    Robert
    Last edited by Trebor76; 10-30-2013 at 07:59 AM. Reason: Fix code tags
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  8. #8
    Registered User
    Join Date
    01-05-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to merge 2 sheets to one and keep header row

    Both of those solutions work but I forgot to add that I needed special paste of values only

  9. #9
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Macro to merge 2 sheets to one and keep header row

    For my code - just change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Macro to merge 2 sheets to one and keep header row

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-05-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Macro to merge 2 sheets to one and keep header row

    Jindon, that works.

    cheeze83 I get an error with that line
    activesheet.pastespecial paste:=xlvalues

    Thanks

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Macro to merge 2 sheets to one and keep header row

    Quote Originally Posted by Capcel View Post
    Jindon, that works.
    Good.
    Quote Originally Posted by Capcel View Post
    cheeze83 I get an error with that line
    activesheet.pastespecial paste:=xlvalues
    Sheet object doesn't have PasteSpecial method.

+ 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. [SOLVED] Macro - Merge 16 sheets, first row problem on empty sheet. Please help.
    By lagiosman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2013, 06:45 AM
  2. [SOLVED] Macro to Compare/Merge 2 Excel Sheets
    By Anthony123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2013, 10:16 AM
  3. [SOLVED] Macro to Merge Sequential Numbered Sheets
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2012, 08:12 AM
  4. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 AM
  5. [SOLVED] Merge one row and header of a sixty-five row worksheet
    By La in forum Excel General
    Replies: 2
    Last Post: 06-23-2006, 09:15 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