Function CountIfString(sCol, sValue)Range(sCol & "1").Selectr = findlastrow(cl(sCol))Range(sCol & "1:" & sCol & r).selectsvSheet = ActiveSheet.NameCreateSheet "TempForCount"Selection.CopySheets("TempForCount").SelectActivesheet.PasteApplication.CutCopyMode = FalseSelection.Autofilterr = FindLastRow(1)ActiveSheet.Range("A1:A" & r).Autofilter field:=1, Criteria1:="=*" & sValue & "*"CountIfString = [=subtotal(3,A:A)-1] ' -1 to not count headerSheets(svSheet).SelectEnd Function