I'm not red hot on EXCEL but after a play I think
returns a 1 if there are a majority of Y's in that range.
I'm not sure how you can do the conditional count you want but I'll have a go.
are you sure you don't want to just use a pivot table of counts of col D vs E ? its under data ..
sorry if this isn't helpful