By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

Become an Σxpert at Σxcel.com

 


CountIfString(sCol,sValue) - counts the # of times the svalue appears in sCol



Function CountIfString(sCol, sValue)

Range(sCol & "1").Select
r = findlastrow(cl(sCol))
Range(sCol & "1:" & sCol & r).select
svSheet = ActiveSheet.Name
CreateSheet "TempForCount"

Selection.Copy
Sheets("TempForCount").Select
Activesheet.Paste
Application.CutCopyMode = False
Selection.Autofilter
r = FindLastRow(1)
ActiveSheet.Range("A1:A" & r).Autofilter field:=1, Criteria1:="=*" & sValue & "*"
CountIfString = [=subtotal(3,A:A)-1] ' -1 to not count header
Sheets(svSheet).Select
End Function