Add the FIND function to find the cell, and use the ISNUMBER function to judge the result. The formula is = sumproduct ((month ($ c $2: $ c $5)&; "month" = f $1) * isnumber ((find ($ e2, $ a $2: $ a $5)), just modify it according to your data location.
The following are instructions for use:
Search of search function and judgment of ISNUMBER function