Thanks for the reply, Macropod. I've attached an excel file that contains some formulae that I used, including the countifs and sumproduct together. Please see if there is another way to solve the problem. Many thanks.
Thanks Pecoflyer for the reply too. No, I just colored the cell for identification. No special formatting.