Function CountStr(somestr, target) Dim a, count As Integer a = InStr(1, somestr, target) Do While a > 0 count = count + 1 a = InStr(a + 1, somestr, target) Loop CountStr = count End Function ÔËÐУºMsgBox CountStr("ASAASDWA", "A") '=4 MsgBox CountStr("ASAASDWA", "B") '=0