=SUMIFS(TheRangeOfBasePayOnSheet2, TheRangeOfCountryOnSheet2, CountryInRowOnSheet1, TheRangeOfJobCodeOnSheet2, JobCodeInRowOnSheet1)