[COLOR="Navy"]Sub[/COLOR] MG14Mar23
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dic1 [COLOR="Navy"]As[/COLOR] Object
[COLOR="Navy"]Dim[/COLOR] Dic2 [COLOR="Navy"]As[/COLOR] Object
[COLOR="Navy"]Dim[/COLOR] k
[COLOR="Navy"]Dim[/COLOR] Num [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]With[/COLOR] Sheets("Sheet1")
[COLOR="Navy"]Set[/COLOR] Rng = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Set[/COLOR] Dic2 = CreateObject("scripting.dictionary")
Dic2.CompareMode = vbTextCompare
[COLOR="Navy"]Set[/COLOR] Dic1 = CreateObject("scripting.dictionary")
Dic1.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
Temp = Dn.Offset(, 1)
[COLOR="Navy"]If[/COLOR] Not Dic1.Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Set[/COLOR] Dic2 = CreateObject("scripting.dictionary")
Dic2.CompareMode = vbTextCompare
Dic2.Add Temp, 1 '[COLOR="Green"][B]Dn[/B][/COLOR]
Dic1.Add Dn.Value, Dic2
[COLOR="Navy"]Else[/COLOR]
[COLOR="Navy"]If[/COLOR] Not Dic1(Dn.Value).Exists(Temp) [COLOR="Navy"]Then[/COLOR]
Dic1(Dn.Value).Add (Temp), 1 '[COLOR="Green"][B]Dn[/B][/COLOR]
[COLOR="Navy"]Else[/COLOR]
Dic1(Dn.Value).Item(Temp) = Dic1(Dn.Value).Item(Temp) + 1
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]Dim[/COLOR] g
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] ntemp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
ReDim Ray(1 To Dic1.Count, 1 To 2)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] k [COLOR="Navy"]In[/COLOR] Dic1.keys
c = c + 1
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] g [COLOR="Navy"]In[/COLOR] Dic1.Item(k)
[COLOR="Navy"]If[/COLOR] Dic1.Item(k)(g) > ntemp [COLOR="Navy"]Then[/COLOR]
Ray(c, 1) = k
Ray(c, 2) = g
Num = Dic1.Item(k)(g)
[COLOR="Navy"]End[/COLOR] If
ntemp = Dic1.Item(k)(g)
[COLOR="Navy"]Next[/COLOR] g
[COLOR="Navy"]Next[/COLOR] k
Range("C1").Resize(Dic1.Count, 2) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]