All the ranges should be in equal size. The last range INDEX(INDIRECT("'"&B$41&"'!$P$4:$T$300")... it should be $P$4:$T$430.
Try this version,
=IFERROR(COUNTIFS(INDIRECT("'"&B$41&"'"&"!G4:G430"),">="&B$3,INDIRECT("'"&B$41&"'"&"!G4:G430"),"<"&EDATE(B$3,1),INDEX(INDIRECT("'"&B$41&"'!P4:T430"),0,MATCH($A42,INDIRECT("'"&B$41&"'!P3:T3"))),"<>"),"")
Also, C3 to down & across, you can reduce the formula to,
=IFERROR(COUNTIF(INDIRECT("'"&TEXT(B3,"mmmm")&"'!G4:G430"),B3),"")
Then apply a custom cell format to hide the zero values as
0;;;
INDIRECT is volatile function. if you have many of them will make the calculation slow.
Bookmarks