Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
cTimes = (Len(sString) - Len(Replace(sString, sSubstring, ""))) _
/ Len(sSubstring) sMsg = sSubstring & " occurs" & cTimes & " times" & vbNewLine ipos = 0 For i = 1 To cTimes ipos = InStr(ipos + 1, sString, sSubstring) sMsg = sMsg & "#" & i & " occurs at: " & ipos & vbNewLine Next i MsgBox sMsg -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... What is the easiest way to count the number of occurences of a substring within a string AND the starting position of each substring? For Example: String = "dog 123 cat 452 if 6754 dog" SubString = "dog" Occurences of SubString = 2 Starting Position of SubString = 1 and 26 Thanks EM |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
array formulas counting substrings across rows | Excel Worksheet Functions | |||
counting starting with a number other than 1 | Excel Discussion (Misc queries) | |||
Counting Starting Digits | Excel Worksheet Functions | |||
Counting Positions | Excel Programming | |||
counting cells in a column based on thier color | Excel Programming |