Hi Bernd,
Your suggestion is excellent! However, I would like to list only the
subsequences that appear 2 times or more. That ones that were observed
only one time should not be listed.
Thanks in advance,
Luciano
On 15 abr, 07:42, Bernd P wrote:
Hello Luciano,
If I understand you correctly, the correct result for your example is:
AG * * *3
GA * * *3
AGG * * 2
AGGA * *2
GAG * * 2
GG * * *2
GGA * * 2
You can get this if you array-enter into A3:B9:
=GSort(pfreq(TRANSPOSE(GenSubStrings(A1))),"DA","N S","21")
GSort you will find hehttp://www.sulprobil.com/html/sort_vba.html
Pfreq is hehttp://www.sulprobil.com/html/pfreq.html
Function GenSubStrings(s As String) As Variant
ReDim v(1 To 10000) As Variant
Dim i As Long, j As Long, k As Long
'Generate all substrings of s with length 2 to Len(s)-1
For i = 2 To Len(s) - 1
* * For j = 1 To Len(s) - i + 1
* * * * k = k + 1
* * * * v(k) = Mid(s, j, i)
* * Next j
Next i
ReDim Preserve v(1 To k) As Variant
GenSubStrings = v
End Function
Regards,
Bernd