+ Reply to Thread
Results 1 to 3 of 3

Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

  1. #1
    Registered User
    Join Date
    04-20-2015
    Location
    Norway
    MS-Off Ver
    360
    Posts
    24

    Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

    Hi there!
    I’m struggling with the last part(s) of a project.

    I have two sheets with data and both contain a row specific ID in all rows of column A. The matching ID can be found in only one row in each sheet. I’m trying to merge rows from the two sheets if they contain the same ID in column A.

    Sheets: “Data1”, “Data2”, and “Merged Data”
    The idea is to organize the “Merged Data” sheet like this:
    Data from “Data1” in the first 62 columns, one blank column, then the data from “Data2” in the next xx columns.

    Problem:
    - The matching IDs are in random rows.
    - There is data in an unknown number of columns in “Data2” (however, no more than 30)
    - The number of rows is unknown in both “Data1” and “Data2”.

    I’ve attached a short example of the workbook, and included how I picture the result.
    The code I’ve managed to put together only inputs the new sheet and gets me the headers – I really have no clue on how to get the rest.
    Please Login or Register  to view this content.
    I can complete the project if someone can help me with this - And, of course, I’ll be very thankful!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

    Find number of rows in Data1 LR1

    Please Login or Register  to view this content.
    Find number of rows in Data2 LR2

    Please Login or Register  to view this content.
    A simple macro to copy Data1 to MergedData

    Please Login or Register  to view this content.
    A simple Macro to insert a formula in columns 63 onwards to match ID and copy data.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-21-2015 at 07:10 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    04-20-2015
    Location
    Norway
    MS-Off Ver
    360
    Posts
    24

    Re: Macro for copying rows in sheet1 to end of existing rows in sheet2 based on criteria

    Thank you, mehmetcik! This works very well

    I changed a few things to get it like I wanted it.
    Please Login or Register  to view this content.
    Thanks again, this is very helpful!
    Last edited by Karl Gustaf Karsten; 10-22-2015 at 10:09 AM.

+ 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. automatically copying rows to an existing spreadsheet based on criteria
    By Jocatlett in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2013, 07:21 PM
  2. Replies: 2
    Last Post: 10-16-2012, 11:34 AM
  3. [SOLVED] macro to copy the formulas in Sheet2 to as many rows as rows available in Sheet1
    By flakedew in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-21-2012, 04:52 AM
  4. Replies: 3
    Last Post: 06-06-2012, 05:36 AM
  5. [SOLVED] Copying Data from Sheet1 to sheet2 based on criteria for copy
    By pprane in forum Excel General
    Replies: 1
    Last Post: 04-22-2012, 02:32 AM
  6. Copying Data from Sheet1 to sheet2 based on criteria for copy
    By pprane in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2012, 02:07 AM
  7. Help! Hiding rows in sheet2 based on values in sheet1
    By Oti in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2011, 12:47 PM
  8. Macro to copy values from Sheet1 to Sheet3, based on criteria in Sheet2
    By John74 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2010, 04:55 PM

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