Function GopLop(ByVal iStr As String) As String
Dim Arr(), Stt(), S, Res$
Dim tmp$, iKey$, sN&, n&, L&, i&, j&
If iStr = Empty Then Exit Function
ReDim Arr(1 To 100, 1 To 2)
S = Split(iStr, ",")
With CreateObject("scripting.dictionary")
For n = 0 To UBound(S)
tmp = S(n)
L = Len(tmp)
For j = L To 1 Step -1
If IsNumeric(Mid(tmp, j, 1)) = False Then
iKey = Mid(tmp, 1, j)
If .exists(iKey) = False Then
k = k + 1
.Add iKey, k
Arr(k, 1) = iKey
Arr(k, 2) = "," & Replace(tmp, iKey, "")
Else
ik = .Item(iKey)
Arr(ik, 2) = Arr(ik, 2) & "," & Replace(tmp, iKey, "")
End If
Exit For
End If
Next j
Next n
End With
For i = 1 To k
tmp = Arr(i, 1)
ReDim Stt(-1 To 100)
S = Split(Arr(i, 2), ",")
For j = 1 To UBound(S)
Stt(CLng(S(j))) = "1"
Next j
For j = 1 To 99
If Stt(j) = "1" Then
If Stt(j - 1) = Empty Then
Res = Res & "," & tmp & j
End If
If Stt(j + 1) = Empty Then
If Stt(j - 1) = "1" Then
If Stt(j - 2) = Empty Then
Res = Res & "," & tmp & j
Else
Res = Res & "-->" & tmp & j
End If
End If
End If
End If
Next j
Next i
GopLop = Mid(Res, 2, Len(Res))
End Function