[COLOR="Navy"]Sub[/COLOR] MG26Apr33
'[COLOR="Green"][B]Align Data in columns "A/B & E/F" rows 32 to 45[/B][/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] oval [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] ColA [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] ColE [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Q
[COLOR="Navy"]Dim[/COLOR] aVal [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] eVal [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] K [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("A32:A45")
ReDim Ray(1 To Rng.Count * 2, 1 To 6)
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]For[/COLOR] col = 1 To 4 [COLOR="Navy"]Step[/COLOR] 3
oval = IIf(col = 1, Dn, Dn.Offset(, 4))
[COLOR="Navy"]If[/COLOR] oval <> "" [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] Not .Exists(oval) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] col = 1 [COLOR="Navy"]Then[/COLOR]
ColA = 1: ColE = 0
aVal = Dn.Offset(, 1)
eVal = 0
[COLOR="Navy"]Else[/COLOR]
ColE = 1: ColA = 0
eVal = Dn.Offset(, 5)
aVal = 0
[COLOR="Navy"]End[/COLOR] If
.Add oval, Array(ColA, ColE, 1, aVal, eVal)
[COLOR="Navy"]Else[/COLOR]
Q = .Item(oval)
[COLOR="Navy"]If[/COLOR] col = 1 [COLOR="Navy"]Then[/COLOR]
Q(0) = Q(0) + 1
Q(3) = Dn.Offset(, 1)
[COLOR="Navy"]ElseIf[/COLOR] col = 4 [COLOR="Navy"]Then[/COLOR]
Q(1) = Q(1) + 1
Q(4) = Dn.Offset(, 5)
[COLOR="Navy"]End[/COLOR] If
Q(2) = Application.sum(Q(0), Q(1))
.Item(oval) = Q
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] col
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
[COLOR="Navy"]If[/COLOR] .Item(K)(2) = 2 [COLOR="Navy"]Then[/COLOR]
rw = rw + 1
Ray(rw, 1) = K: Ray(rw, 2) = .Item(K)(3)
Ray(rw, 5) = K: Ray(rw, 6) = .Item(K)(4)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] K
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
[COLOR="Navy"]If[/COLOR] .Item(K)(0) = 1 And .Item(K)(1) = 0 [COLOR="Navy"]Then[/COLOR]
rw = rw + 1
Ray(rw, 1) = K: Ray(rw, 2) = .Item(K)(3)
Ray(rw, 5) = "": Ray(rw, 6) = ""
[COLOR="Navy"]ElseIf[/COLOR] .Item(K)(0) = 0 And .Item(K)(1) = 1 [COLOR="Navy"]Then[/COLOR]
rw = rw + 1
Ray(rw, 1) = "": Ray(rw, 2) = ""
Ray(rw, 5) = K: Ray(rw, 6) = .Item(K)(4)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] K
Rng.Resize(, 6).ClearContents
Range("A32").Resize(rw, 6) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]