It depends. First thing is to copy the two tables into a single new document.
- Create a new document. Delete the default table. Create a second sheet and delete the table there, too
- Open the "date of birth" document
- Select the table and Copy
- Paste it into Sheet 1 of the new document
- Repeat 2-4 for the "codes" document but paste into Sheet 2
Next get all the names into one table. There will be duplicates but that will be dealt with later.
- Create a third sheet. Keep the table this time
- Copy the column of names from the table on Sheet 1and Paste to column A of this table (select cell A2 then Paste)
- Add a row to the bottom of the table if there is not a blank row at the bottom
- Copy the column of names from the table on Sheet 2 and Paste into column A of this table (select the blank cell at the bottom of column A then Paste)
Next get the birthdates and codes into the table. I will be using the name "Table 1" as the names of the two tables you copy/pasted into this document. If they have a different name, use those names instead.
- In cell B2 put the formula =XLOOKUP(A, Sheet 1::Table 1::A,Sheet 1::Table 1::B,"",0)
- In cell C2 put the formula =XLOOKUP(A, Sheet 2::Table 1::A,Sheet 2::Table 1::B,"",0)
- Select both of those cells.
- Copy
- Select the rest of columns B&C
- Paste
That should have created a table with the names with their associated birthdates and codes. Sort the table by column A to get everything into alphabetical order by name. There will likely be duplicate rows. Manually deleting the duplicate rows might be the quickest way to pare it down, depending on how many you have. If you have a lot of them to delete, formulas can be used to flag them then they can be sorted into one block for one quick deletion. Here is the manual way though:
- Click on the row number to select a row
- Command click on row numbers of other rows to delete to select those other rows.
- When you have a few selected to delete, right click and choose "delete selected rows".
Replace the formulas with their values.
- Select columns B & C (all the cells with formulas)
- Copy
- Use the menu item "Edit->Paste Formula Results" . All the formulas should be gone and the values there instead.
- Sheets 1 and 2 and the tables on them are no longer required. You can delete them and rename Sheet 3 as Sheet 1 (or whatever name of your choosing)