View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Luciano Paulino da Silva Luciano Paulino da Silva is offline
external usenet poster
 
Posts: 77
Default Numbers of repeats of a string

Dear Bernd,
I can not understand why, but I have always to put some string on cell
"A1" to have strings determined if not the code crashes and appear
errors on cells bellow A1.
Have you any idea about what is happening?
Thanks in advance,
Luciano

On 15 abr, 13:32, Luciano Paulino da Silva
wrote:
Dear Bernd,
Thank you very much for the code. It is working fine, but for some
situations the strings size is limiting its use since it takes several
minutes, and even hours to perform the calculation. Unfortunately 90%
of the cases I have strings bigger than 200 characters. :(
Thank you again,
Luciano

On 15 abr, 11:38, Bernd P wrote:

Hello Luciano,


That was left as homework exercise :-)


Here we a
Function ShowRepetitions(v As Variant) As Variant
Dim i As Long, j As Long


On Error Resume Next
Do While v(i, 2) 1
* * i = i + 1
Loop
If v(i, 2) = 1 Then i = i - 1
On Error GoTo 0


ReDim vR(1 To Application.Caller.Rows.Count, 1 To 2) As Variant


For j = 1 To Application.Caller.Rows.Count
* * If j i Then
* * * * vR(j, 1) = ""
* * * * vR(j, 2) = ""
* * Else
* * * * vR(j, 1) = v(j, 1)
* * * * vR(j, 2) = v(j, 2)
* * End If
Next j


ShowRepetitions = vR


End Function


Array-enter:
=showrepetitions(GSort(pfreq(TRANSPOSE(GenSubStrin gs
(A1))),"DA","NS","21"))


Regards,
Bernd