+ Reply to Thread
Results 1 to 11 of 11

Merge worksheets with unique key in common

  1. #1
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Merge worksheets with unique key in common

    Hi,

    I have two worksheets with the same column headers and a unique key in common, Name. I need to merge the two to create a single worksheet with complete records.

    The cases that will be encountered are:
    - there will be exact duplicate records, of which i only want to keep one
    - there will be unique records in each worksheet which i need to retain
    - one worksheet will have blank fields that are filled in on the second worksheet. i need to merge the records to create a single complete record
    - there will be cases where each worksheet has a record for Name and has field entries that do not match, in which case i need worksheet one to take precedence

    Please see attached example with Worksheet 1, Worksheet 2, and Merged worksheet.

    I've searched for days and can't find an answer on how to accomplish this. I thought about reading both tables into access but i have no experience with Access and when I try to bring them both in it doesn't like that the data is duplicated.

    Can anyone help me?
    Thanks!
    Attached Files Attached Files
    Last edited by porpitax2; 03-20-2011 at 02:25 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Merge worksheets with unique key in common

    Roughly how many records do you have in your actual file? Will have a look at this tomorrow if it is still unsolved.

  3. #3
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Merge worksheets with unique key in common

    That would be so great...
    I have about 2000 records in worksheet 1 and 1500 in worksheet 2. There are about 20 fields in each.
    Thank you!

  4. #4
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Merge worksheets with unique key in common

    I posted my question originally on this site: http://www.ozgrid.com/forum/showthre...rds+unique+key

    I didn't receive any responses after four days, which is why I posted here. I tried to delete my other post, but had no luck.
    Last edited by porpitax2; 03-08-2011 at 09:32 PM.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Merge worksheets with unique key in common

    It's important you mention when you post at other forums because we can then avoid the possibility of somebody spending time solving a problem which has already been solved elsewhere. You should have mentioned it at Ozgrid too.

    I think this works for your example. It does assume the two sheets have the same number of columns.
    Please Login or Register  to view this content.
    Last edited by StephenR; 03-09-2011 at 11:34 AM.

  6. #6
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Merge worksheets with unique key in common

    Hi,
    I asked the administrator to delete my posting on Ozgrid since I hadn't had any replies and he didn't do that (should I now go to Ozgrid and state that it was solved on this site?). I've never done forums before, so I apologize for not getting this quite right. I mentioned the cross posting here for until it was deleted on Ozgrid... I guess that logic didn't work out very well. I've been reprimanded so many times trying to do this that I may never try it again! :o)

    But seriously, or even more seriously, thank you Very much for your help. I really can't tell you how much I needed this help and appreciate it. I'll print this out and bring it into work tomorrow to try out.

    Respectfully... Jen

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Merge worksheets with unique key in common

    Jen - let sleeping dogs lie. Just remember for the future.

  8. #8
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Merge worksheets with unique key in common

    Thanks StephenR. I will.

  9. #9
    Registered User
    Join Date
    03-08-2011
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Merge worksheets with unique key in common

    StephenR,
    I just wanted to follow up with you that the program worked beautifully! I've even managed to expand upon it a bit. Thank you so much!!!
    Jen

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Merge worksheets with unique key in common

    Jen - my pleasure, glad it worked.

  11. #11
    Registered User
    Join Date
    02-22-2015
    Location
    Toronto, ON
    MS-Off Ver
    2010
    Posts
    1

    Re: Merge worksheets with unique key in common

    How would you adjust the code to remove the assumption so that the two sheets do not require the same number of columns?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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