HI

AH10: =sumproduct(--($aa$20:$aa$29=AG10),--($Z$20:$Z$29="W"))

Adjust the ranges to suit and copy down. I'm guessing that the merged cells in AA:AD have the data taken from AA.


rylo