Here's an example using Excel's Sumproduct formula, see attached file for result of formula:
=SUMPRODUCT((TableB!$B$1:$Y$1>=DATE(YEAR($B2),MONTH($B2),DAY(1)))*(TableB!$B$1:$Y$1<DATE(YEAR($B2),MONTH($B2)+6,DAY(1)))*(TableB!$B$2:$Y$4)*(TableB!$A$2:$A$4=$A2))