[COLOR="Navy"]Sub[/COLOR] MG17Apr28
[COLOR="Navy"]Dim[/COLOR] Lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Mc [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Mr [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Dr
[COLOR="Navy"]Dim[/COLOR] K
[COLOR="Navy"]Dim[/COLOR] nRng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] DataRay
[COLOR="Navy"]Dim[/COLOR] DRng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]With[/COLOR] Sheets("Sheet3")
[COLOR="Navy"]Set[/COLOR] DRng = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
DRng.Copy .Range("Z1")
.Range("Z1").Resize(DRng.Count).Sort .Range("Z1"), xlAscending
DataRay = .Range("Z1").Resize(DRng.Count)
.Range("Z1").Resize(DRng.Count).ClearContents
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Set[/COLOR] Rng = Sheets("Sheet1").Range("A1").CurrentRegion
MsgBox Rng.Address
ReDim Ray(1 To DRng.Count + 1, 1 To DRng.Count + 1)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dr [COLOR="Navy"]In[/COLOR] DataRay
Ac = Ac + 1
Ray(1, Ac + 1) = Dr
Ray(Ac + 1, 1) = Dr
[COLOR="Navy"]Next[/COLOR] Dr
ReDim oMax(1 To Rng.Rows.Count)
[COLOR="Navy"]For[/COLOR] Mr = 2 To UBound(Ray, 1)
[COLOR="Navy"]For[/COLOR] Mc = 2 To UBound(Ray, 2)
[COLOR="Navy"]For[/COLOR] Rw = 1 To Rng.Rows.Count
[COLOR="Navy"]With[/COLOR] Application
oMax(Rw) = .CountIf(Rng.Rows(Rw), Ray(1, Mc)) + .CountIf(Rng.Rows(Rw), Ray(Mr, 1))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] Rw
Ray(Mr, Mc) = IIf(Application.Max(oMax) = 2, 1, 0)
[COLOR="Navy"]Next[/COLOR] Mc
[COLOR="Navy"]Next[/COLOR] Mr
Sheets("Sheet2").Range("A1").Resize(DRng.Count + 1, DRng.Count + 1) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]