It's WorksheetFunction.CountIf and not Worksheet.Function.CountIf.