[COLOR=navy]Sub[/COLOR] MG15Apr46
[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] Num1 [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] Num2 [COLOR=navy]As[/COLOR] [COLOR=navy]String[/COLOR]
[COLOR=navy]Dim[/COLOR] dn [COLOR=navy]As[/COLOR] Range
[COLOR=navy]Set[/COLOR] rng = Range("A1").CurrentRegion
Lst = Cells("1", Columns.Count).End(xlToLeft).Column
ReDim Ray(1 To Lst * 2 + 1, 1 To Lst * 2 + 1)
[COLOR=navy]For[/COLOR] col = 1 To Lst
[COLOR=navy]For[/COLOR] Rw = 1 To 2
Ac = Ac + 1
Ray(1, Ac + 1) = Cells(Rw, col)
Ray(Ac + 1, 1) = Cells(Rw, col)
[COLOR=navy]Next[/COLOR] Rw
[COLOR=navy]Next[/COLOR] col
[COLOR=navy]For[/COLOR] Mr = 2 To UBound(Ray, 1)
[COLOR=navy]For[/COLOR] Mc = 2 To UBound(Ray, 2)
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] dn [COLOR=navy]In[/COLOR] rng
[COLOR=navy]If[/COLOR] dn = Ray(Mr, 1) [COLOR=navy]Then[/COLOR] Num1 = dn.Row: [COLOR=navy]Exit[/COLOR] For
[COLOR=navy]Next[/COLOR] dn
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] dn [COLOR=navy]In[/COLOR] rng
[COLOR=navy]If[/COLOR] dn = Ray(1, Mc) [COLOR=navy]Then[/COLOR] Num2 = dn.Row: [COLOR=navy]Exit[/COLOR] For
[COLOR=navy]Next[/COLOR] dn
Ray(Mr, Mc) = IIf(Num1 = Num2, 1, 0)
Num1 = "": Num2 = ""
[COLOR=navy]Next[/COLOR] Mc
[COLOR=navy]Next[/COLOR] Mr
Range("B7").Resize(UBound(Ray), UBound(Ray)) = Ray
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
[COLOR="Navy"]Sub[/COLOR] MG16Apr29
[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] Num1 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] Num2 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] k
[COLOR="Navy"]Dim[/COLOR] nRng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range("A1").CurrentRegion
ReDim Ray(1 To Rng.Count + 1 + 1, 1 To Rng.Count + 1)
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] col = 1 To Rng.Columns.Count
[COLOR="Navy"]Set[/COLOR] nRng = Rng(col).Resize(Rng.Rows.Count)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] nRng
.Item(Dn.Value) = Dn
Ac = Ac + 1
Ray(1, Ac + 1) = .Item(Dn.Value)
Ray(Ac + 1, 1) = .Item(Dn.Value)
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]Next[/COLOR] col
ReDim oMax(1 To 2)
[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 2
[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(1), oMax(2)) = 2, 1, 0)
[COLOR="Navy"]Next[/COLOR] Mc
[COLOR="Navy"]Next[/COLOR] Mr
Range("B7").Resize(.Count + 1, .Count + 1) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
[COLOR="Navy"]Sub[/COLOR] MG17Apr33
[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
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 2)
[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 2
[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(1), oMax(2)) = 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]