Merge two Excel Files

bull city bob

New Member
Joined
Feb 6, 2006
Messages
14
My first Excel file is 17,000 lines. Columns a-h have patient data. Columns i-j have comments added when the data is reviewed (its a list of changes).

Second Excel file has 44,000 lines. Its cumulative from the first file.

I want to compare columns a-h of both files. If they are identical, I want to transfer the comments from columns i-j of the first file over to the second file.

I believe I should end up with a table of 44,000 lines and it will show the comments that were made on the original file (columns i-j). That way I can see which changes have already been reviewed.

I'm just getting to the intermediate lever in Access, and barely starting to know how to play around with SQL.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
What you could consider doing is upload the files into 2 separate tables in Access (DoCmd.TransferSpreadsheet) will work then you can run some SQL code to update the comments. That would work something like this:

Function sqlUWRCode()
DoCmd.SetWarnings False
sql = "UPDATE [XIAP Stub dataset New] INNER JOIN [Underwriter Codes] ON [XIAP Stub dataset New].[Uwr ID Code] = [Underwriter Codes].[System Code]"
sql = sql & "SET [XIAP Stub dataset New].[Uwr ID Code] = [Underwriter Codes]![XIAP Code];" ' The table to update 'the field and content to add
Debug.Print sql
DoCmd.RunSQL sql
DoCmd.SetWarnings True
End Function
 
Upvote 0
Upload the 2 spreadsheet onto 2 tables in Access. In query design view, use outer joins to link the two tables (show all records from the 2nd, bigger table). Make sure you have a join for ever column in A through H. Select spreadsheet 2's columns A through H to be displayed. Then select spreadsheet 1's columns I through J to be displayed after spreadsheet 2's columns A through H. The results will show all the records in spreadsheet 2 and the comments from spreadsheet 1 associated with those records
 
Upvote 0
Thanks everyone for your help. I basically used the suggestion of outer join (I did a union). Now the problem I'm running in to is that the updated file has duplicate lines. Apparently when the patient data is updated, it sends over the entire record, even fields that did not change!

So the solution works, now I have to work on convincing the end user that they don't need all those duplicate unchanged fields. Because, Union works but eliminates duplicates. Outer join does not work because, since there are duplicate lines, Access does not know which line to put the comments from columns I, J.
 
Upvote 0

Forum statistics

Threads
1,213,568
Messages
6,114,348
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top