Something like this?
VB Code:
Sub SubStrings(strFirst As String, strSecond As String) 'counter(i) will contain the no. of times a substring 'length i of strSecond appears in strFirst Dim tmparr() As String Dim tmpStr As String Dim Counter() As Long Dim i As Long, j As Long ReDim Counter(Len(strSecond) ) For i = 1 To Len(strSecond) For j = 1 To Len(strSecond) - i + 1 tmpStr = Mid$(strSecond, j, i) tmparr() = Split(strFirst, tmpStr, , vbBinaryCompare) Counter(i) = UBound(tmparr()) + Counter(i) Next j Next i End Sub
