[COLOR="Navy"]Sub[/COLOR] MG28Aug42
[COLOR="Navy"]Dim[/COLOR] Rng1 [COLOR="Navy"]As[/COLOR] Range, Rng2 [COLOR="Navy"]As[/COLOR] Range, Ray [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] cols [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Num [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] nRw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]With[/COLOR] Sheets("Sheet1")
[COLOR="Navy"]Set[/COLOR] Rng1 = .Range("D5", .Range("D5").End(xlDown))
[COLOR="Navy"]Set[/COLOR] Rng2 = .Range("D14", .Range("D14").End(xlDown))
[COLOR="Navy"]End[/COLOR] With
Ray = Array(Rng1, Rng2)
[COLOR="Navy"]For[/COLOR] n = 0 To 1
Ac = 0: c = 0
cols = Ray(n).Offset(, 1).SpecialCells(xlConstants).Count
ReDim nRay(1 To Application.Max(Ray(n).Offset(, 1)) + 1, 1 To cols * 2)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Ray(n)
[COLOR="Navy"]If[/COLOR] Not IsEmpty(Dn.Offset(, 1)) [COLOR="Navy"]Then[/COLOR]
Ac = Ac + 1
nRay(1, Ac) = Dn.Value
[COLOR="Navy"]For[/COLOR] Rw = 1 To Dn.Offset(, 1).Value
nRay(Rw + 1, Ac) = Rw
[COLOR="Navy"]Next[/COLOR] Rw
Ac = Ac + 1
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
Num = IIf(n = 0, 0, nRw + 5)
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("C3").Offset(Num).Resize(UBound(nRay, 1), (cols * 2) - 1)
.Value = nRay
.Borders.Weight = 2
.Columns.AutoFit
[COLOR="Navy"]End[/COLOR] With
nRw = UBound(nRay, 1)
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]