Have a look at the Countif function in Excel help.