+ Reply to Thread
Results 1 to 10 of 10

Match two rows of different sheets and copy to new sheet

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    5

    Match two rows of different sheets and copy to new sheet

    Hi all,

    I'm new here so please forgive me if I don't provide you with enough info, I'll try my best!

    Ok, so I need some assistance please - I have a workbook with two sheets currently. Sheet 1 contains hundreds of rows complete with personal data having been logged onto a service desk type system, column A being the individuals name. Sheet 2 contains a list of 70 names in column A; those are the people I'm interested in - but they are not the only people to have information on the system.

    What I'm looking to achieve is to cross reference Sheet 2 Column A with Sheet 1 Column A and copy the entire row onto a new sheet where they both match. I have searched this and the answers found assume only one match will be found; in this instance they could be multiple matches for the individual named in Sheet 2 Column 1, I need all rows for that match copied, before excel moves onto looking for the next individual.

    Hope that makes sense - any guidance would be much appreciated as I'm struggling to work this out.

    Thanks in advance,

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Match two rows of different sheets and copy to new sheet

    Try this macro:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Match two rows of different sheets and copy to new sheet

    Thank you - it works in that it copies those names to a new sheet, but it doesn't copy the entire row for that person - how do I change this?

  4. #4
    Registered User
    Join Date
    10-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Match two rows of different sheets and copy to new sheet

    Actually it doesn't seem to extract the correct individuals, but any individual?

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Match two rows of different sheets and copy to new sheet

    You could try

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  6. #6
    Registered User
    Join Date
    10-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Match two rows of different sheets and copy to new sheet

    Thanks Ollie - though Dubugger doesn't like the following?

    pvt_obj_Recordset.Open pvt_str_Query, pvt_obj_Connection, adOpenDynamic, adLockReadOnly

    Any ideas?

  7. #7
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Match two rows of different sheets and copy to new sheet

    It worked fine when I tested a little, maybe you have some formatting issues. Try changing this line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

    and it also copied the entire row for me as I tested it. Maybe try changing this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.


    Edit: if it still doesn't work, maybe post a sample of your workbook.
    Last edited by millz; 10-07-2013 at 10:26 AM.

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Match two rows of different sheets and copy to new sheet

    Quote Originally Posted by CalumRiley View Post
    Thanks Ollie - though Dubugger doesn't like the following?

    pvt_obj_Recordset.Open pvt_str_Query, pvt_obj_Connection, adOpenDynamic, adLockReadOnly

    Any ideas?
    Calum, without the error message details it is a bit difficult to understand what is happening. Are the worksheet names perhaps different from Sheet1 and Sheet2? If so, please specify the correct names in he code

  9. #9
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Match two rows of different sheets and copy to new sheet

    PS if they are called Sheet1 and Sheet2, then please post a copy of the workbook and I'll sort it out

  10. #10
    Registered User
    Join Date
    10-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Match two rows of different sheets and copy to new sheet

    Millz - your time to assist me is extremely appreciated - thank you so much. Your macro worked a treat!

+ 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. Match two Columns of two Sheets and Copy Matched Rows to a Third Sheet
    By Par in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2012, 10:16 AM
  2. Replies: 0
    Last Post: 10-25-2012, 03:38 PM
  3. If match between two sheets, copy adjacent cell from sheet 2 to sheet 1?
    By VBnoob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2011, 04:02 AM
  4. Match cells from Multiple sheets and copy rows
    By Kilcup01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2011, 12:43 PM
  5. Match column from sheet 2 to sheet 1 and copy rows if match exists.
    By GravityInvert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2008, 01:42 PM

Tags for this Thread

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