I tried the following but still doesnt work:

Dim num As Integer

num = Application.CountIf(Sheets(1).Range("B"), "x")

MsgBox num

It throws up an application or object defined error