
Sub conta_valori_cella()
Dim x As Integer, i As Integer, col As Integer
Dim conta As Integer, a As String, b As String
a = ""
b = ""
col = 2
x = Len([a1])
For i = 1 To x
a = Mid([a1], i, 1)
conta = conta + 1
If i > 1 And a <> b Then
Cells(1, col) = conta - 1
col = col + 1
conta = 1
ElseIf i = x Then
Cells(1, col) = conta
End If
b = a
Next
End Sub
|
Function count_of(text As String, find As String) As Integer
count_of = Len(Replace(text, find, find & "*")) - Len(text)
End Function |
Option Explicit
Function conta_valori(s As String)
Dim my_coll As Collection, i As Integer, v As Variant, m As String
Set my_coll = New Collection
On Error Resume Next
For i = 1 To Len(s)
my_coll.Add Mid(s, i, 1), Mid(s, i, 1)
Next
On Error GoTo 0
For Each v In my_coll
m = m & v & ": " & count_of(s, v) & "; "
Next
conta_valori = Replace(m & "@", "; @", "")
End Function
Private Function count_of(ByVal text As String, ByVal find As String) As Integer
count_of = Len(Replace(text, find, find & "*")) - Len(text)
End Function |
Sub conta_cella()
Dim x As Integer, i As Integer, col As Integer
Dim conta As Integer, a As String, b As String
b = ""
col = 2
x = [counta(a:a)]
For i = 1 To x
a = Cells(i, 1)
conta = conta + 1
If i > 1 And a <> b Then
Cells(1, col) = b & ": " & conta - 1
col = col + 1
conta = 1
End If
If i = x Then
Cells(1, col) = a & ": " & conta
End If
b = a
Next
End Sub |
