[COLOR="Navy"]Sub[/COLOR] MG25Sep36
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Rrng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Brng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] B [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] R [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] max [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] TRng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] t [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 2)
[COLOR="Navy"]If[/COLOR] Rng(1).Font.ColorIndex = 3 [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Not Dn.Font.ColorIndex = 3 [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Set[/COLOR] TRng = Rng(1).Resize(Dn.Row - 1)
[COLOR="Navy"]Set[/COLOR] Rng = Range(Cells(Dn.Row, 1), Cells(Rows.Count, 1).End(xlUp))
[COLOR="Navy"]Exit[/COLOR] For
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]If[/COLOR] Not TRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] t [COLOR="Navy"]In[/COLOR] TRng
c = c + 1
ray(c, 1) = t: ray(c, 2) = 3
[COLOR="Navy"]Next[/COLOR] t
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Dn.Font.ColorIndex = 3 [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] Rrng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rrng = Dn
[COLOR="Navy"]Else[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rrng = Union(Rrng, Dn)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Else[/COLOR]
[COLOR="Navy"]If[/COLOR] Brng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Set[/COLOR] Brng = Dn
[COLOR="Navy"]Else[/COLOR]
[COLOR="Navy"]Set[/COLOR] Brng = Union(Brng, Dn)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]If[/COLOR] Rrng [COLOR="Navy"]Is[/COLOR] Nothing Or Brng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR] [COLOR="Navy"]Exit[/COLOR] [COLOR="Navy"]Sub[/COLOR]
max = Application.max(Rrng.Areas.Count, Brng.Areas.Count)
[COLOR="Navy"]For[/COLOR] n = 1 To max
[COLOR="Navy"]If[/COLOR] n <= Rrng.Areas.Count [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] Rrng.Areas(n)
c = c + 1
ray(c, 1) = R: ray(c, 2) = 3
[COLOR="Navy"]Next[/COLOR] R
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]If[/COLOR] n <= Brng.Areas.Count [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] B [COLOR="Navy"]In[/COLOR] Brng.Areas(n)
c = c + 1
ray(c, 1) = B: ray(c, 2) = 1
[COLOR="Navy"]Next[/COLOR] B
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]For[/COLOR] n = 1 To UBound(ray)
[COLOR="Navy"]With[/COLOR] Cells(n, 3)
.Value = ray(n, 1)
.Font.ColorIndex = ray(n, 2)
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]