L
Legacy 462862
Guest
Hi,
I've used the following to identify the most frequently occurring text in my sheet:
- - -
Function Freq(rng As Range) As String
Dim cll As Range
Dim lngCount As Long
Dim lngMax As Long
Dim str As String
Set dic = CreateObject("scripting.dictionary")
On Error Resume Next
For Each cll In rng
If cll.Value <> "" Then
dic(cll.Value) = dic(cll.Value) + 1
lngCount = dic(cll.Value)
If lngCount > lngMax Then
lngMax = lngCount
str = cll.Value
End If
End If
Next
On Error GoTo 0
Freq = str
End Function
- - -
Does anyone know what needs to be changed to identify the 2nd, 3rd, 4th, 5th etc? Or a different way of doing it?
Thanks!
I've used the following to identify the most frequently occurring text in my sheet:
- - -
Function Freq(rng As Range) As String
Dim cll As Range
Dim lngCount As Long
Dim lngMax As Long
Dim str As String
Set dic = CreateObject("scripting.dictionary")
On Error Resume Next
For Each cll In rng
If cll.Value <> "" Then
dic(cll.Value) = dic(cll.Value) + 1
lngCount = dic(cll.Value)
If lngCount > lngMax Then
lngMax = lngCount
str = cll.Value
End If
End If
Next
On Error GoTo 0
Freq = str
End Function
- - -
Does anyone know what needs to be changed to identify the 2nd, 3rd, 4th, 5th etc? Or a different way of doing it?
Thanks!