=AVERAGE(IF(MONTH(B$5:B$200)=J2,H$5:H$200))

The above array formula is used in 12 different cells, for each month of the
year. All of the formulas generate the proper values, except for Month 1
(January).

For January, and January ONLY, this formula only works when the range is the
exact same size as the last date in the worksheet.

For example:
Row 65 contains the last date (in Column B), Rows greater than 65 contain
null values for the date (Column B), and null values to average (Column H).
So when J2 has a value of 1, the formula only works when I change it to the
last row as follows:

=AVERAGE(IF(MONTH(B$5:B$65)=J2,H$5:H$65))

Can someone give me a hint as to what may be the problem here?

Thanks,
Bernie
p.s.
Data is sorted by date (column B), and the formula works for all months
except January.