An easy way to solve this problem is to use the SUMIFS function, as explained below.
SUMIFS function
TheSUMIFS functioncan sum values in ranges based on multiple criteria.
The references to F5 and G5 arerelativeand change at each new row.
- Note: SUMIFS is in a group of functions that split criteria into two parts.
As a result, the syntax used for operators is different from other functions.See this article for details.