I have two tables, given as Table 1 and Table 2 below:

Now, if for a given Code, there are values in Table 1 which match Table 2, then I want the rows in Table 1 to be subtracted using the rows from Table 2. For example for Code AAA, since Val1 = 100 in Table 1, then I must subtract 10, 20, and 10 from it to get the final value of 60. Similarly for AAA Val2, it is 200 - 5 - 30 - 50 = 115.
After this is done, I then want to merge the rows from Table 2 onto Table 1 such that I get the final table below:

I have also attached a sample excel file with the data
If anyone can help me with this it would be greatly appreciated, thank you!