[COLOR="Navy"]Sub[/COLOR] MG12Jun32
[COLOR="Navy"]Dim[/COLOR] Ray [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Dic [COLOR="Navy"]As[/COLOR] Object, R [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] St, Sa [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] p [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = ActiveSheet.Range("A1:CV10")
[COLOR="Navy"]With[/COLOR] CreateObject("System.Collections.ArrayList")
ReDim nray(1 To UBound(Ray, 1), 1 To UBound(Ray, 2))
[COLOR="Navy"]Set[/COLOR] Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] n = 1 To UBound(Ray, 1)
[COLOR="Navy"]If[/COLOR] Not Dic.exists(Ray(n, 1)) [COLOR="Navy"]Then[/COLOR]
Dic.Add Ray(n, 1), n
.Add Ray(n, 1)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
.Sort
R = .toarray
[COLOR="Navy"]For[/COLOR] Sa = 0 To UBound(R)
c = c + 1
[COLOR="Navy"]For[/COLOR] Ac = 1 To UBound(Ray, 2)
[COLOR="Navy"]If[/COLOR] Ac = 1 [COLOR="Navy"]Then[/COLOR]
nray(c, Ac) = R(Sa)
[COLOR="Navy"]Else[/COLOR]
nray(c, Ac) = Ray(Dic(R(Sa)), Ac)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] Sa
[COLOR="Navy"]End[/COLOR] With
Sheets("Sheets2").Range("A1").Resize(UBound(Ray, 1), UBound(Ray, 2)) = nray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]