If cells D4:D6
are Text, you're best off to change them to Dates (like 02/01/2018
), that use custom cell formatting of mmmm
to display only the month. They will be easier to deal with for a number of reasons.
Then, "do this": (formulas below image)

Note that my Regional Settings are probably different from yours, so your dates will probably be entered as MM/DD/YYYY as opposed to YYYY-MM-DD.
Text from the image:
Cell D4 : 2018-02-01
Cell D5 : =EDATE(D4,1)
"Fill" or Copy D5 into D6 etc…
Cell E4 : =COUNTIFS($A:$A,">="&$D4,$A:$A,"<"&EDATE($D4,1),$B:$B,E$3)
"Fill" or Copy E4 into E4:G6
More Info:
EDIT:
If your "Month" columns must be text instead of the more logical "date-formatted-as-mmmm
", then you'll need to use this formula instead:
=COUNTIFS($A:$A,">="&DATEVALUE($D4&" 1, " & YEAR($A$2)),$A:$A,"<"&EDATE(DATEVALUE($D4&" 1, " & YEAR($A$2)),1),$B:$B,E$3)
Notice how it's longer, more confusing, and since you're no longer specifying a year, it's assuming you want to use "the year of the date in cell A2
", and may have other issues at some point... Unless it's homework, in which case it will be fine either way. :-)