CountIN

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
Yuo know it seemed like I saw a VBA function to do this, but I couldn't fund it and ended up writing my own. Is there a function (not neccasarily in Excel, but in VBA) that counts the occurances of a substring within a string?
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,870
Hi Oorang

I use:

(Len(str) - Len(Replace(str, substr, ""))) / Len(substr)

HTH
PGC
 

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
I was also using a string manipulation to pull it out. (BTW I like that method.)
 

Watch MrExcel Video

Forum statistics

Threads
1,114,041
Messages
5,545,687
Members
410,698
Latest member
Wloven
Top