I have a large genealogical dataset which I exported to excel to enter in a specific programme to produce coefficients of relatedness. But the excel export is formatted differently to what the descent programme requires. I require my excel sheet to look like:

**Ego ID - Father ID - Mother ID - Sex** 

But at the moment I have three sheets of the following in one workbook:

**Sheet 1: Ego ID - Surname - Give Name - Sex** 

**Sheet 2: Family ID - Father ID - Mother ID**

**Sheet 3: Family ID - Child ID\*\*** 

So I believe I need to code in VBA to do the following:

* If family ID in sheet 3 matches the family ID in sheet 2 then copy all the children in the family to the family ID row in sheet 2 after the mother ID (e.g. - **Family ID - Father ID - Mother ID - Child ID - CHILD ID**)
* Then would need to code that if the child ID in sheet 2 matches the Ego ID in sheet 1 then copy the relevant mother and father ID into the Ego ID row after Sex in sheet 1 (e.g. **Ego ID - Surname - Given Name - Sex - Father ID - Mother ID**)

Can anyone let me know if this is even possible? I have never coded in excel before and I have no idea where to start so any bit of help will be really appreciated.

Thanks!