You can use SUMIFS
and SUMPRODUCT
.
Let's say Sheet1 column A has the countries, Sheet1 column B has the IDs, Sheet1 column C has the values, Sheet2 column A has the IDs to match and all tables have headers in row 1. This formula is being put on Sheet1.
=SUMPRODUCT(SUMIFS($C$2:$C$100,$A$2:$A$100,"CountryName",$B$2:$B$100,Sheet2!$A$2:$A$100))
SUMIFS
gives the sum of range C2:C100, for which the range A2:A100 corresponds to the text "Countryname", and for which the IDs in range B2:B100 correspond to the IDs on the other sheets. The values returned are in an array, and as such, you uses SUMPRODUCT
to sum them up.
Change the range references accordingly.