Could you upload a sample of the workbook?

Take a look at using the DCOUNT function: it allows use of multiple criteria and ideally suited to the task.

A SUMPRODUCT formula is another option.