[COLOR="Navy"]Sub[/COLOR] MG09Jan53
'[COLOR="Green"][B]Mk2[/B][/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng1 [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] oMax, Q [COLOR="Navy"]As[/COLOR] Variant, RngC [COLOR="Navy"]As[/COLOR] Range, RngD [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Rng2 [COLOR="Navy"]As[/COLOR] Range, Ray [COLOR="Navy"]As[/COLOR] Variant, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] nn [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]With[/COLOR] Sheets("WS1")
[COLOR="Navy"]Set[/COLOR] Rng1 = .Range("C2", .Range("C" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Sheets("WS2")
[COLOR="Navy"]Set[/COLOR] Rng2 = .Range("D2", .Range("D" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
Ray = Array(Rng1, Rng2)
oMax = Application.Max(Rng1.Count, Rng2.Count)
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] Ac = 0 To 1
nn = 0
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Ray(Ac)
[COLOR="Navy"]If[/COLOR] Not .exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
ReDim nRay(1 To oMax, 1 To 2)
[COLOR="Navy"]Set[/COLOR] nRay(1, Ac + 1) = Dn
.Add Dn.Value, Array(nRay, 1, nn)
[COLOR="Navy"]Else[/COLOR]
Q = .Item(Dn.Value)
[COLOR="Navy"]If[/COLOR] Ac = 0 [COLOR="Navy"]Then[/COLOR]
Q(1) = Q(1) + 1
[COLOR="Navy"]Set[/COLOR] Q(0)(Q(1), Ac + 1) = Dn
[COLOR="Navy"]Else[/COLOR]
Q(2) = Q(2) + 1
[COLOR="Navy"]Set[/COLOR] Q(0)(Q(2), Ac + 1) = Dn
[COLOR="Navy"]End[/COLOR] If
.Item(Dn.Value) = Q
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Dim[/COLOR] k [COLOR="Navy"]As[/COLOR] Variant, nMax [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] k [COLOR="Navy"]In[/COLOR] .Keys
nMax = Application.Max(.Item(k)(1), .Item(k)(2))
[COLOR="Navy"]For[/COLOR] n = 1 To nMax
[COLOR="Navy"]If[/COLOR] .Item(k)(0)(n, 1) = .Item(k)(0)(n, 2) [COLOR="Navy"]Then[/COLOR]
.Item(k)(0)(n, 1).Delete shift:=xlUp
.Item(k)(0)(n, 2).Delete shift:=xlUp
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]Next[/COLOR] k
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]