Группировать каждый перечень сайтов получилось.
Код |
---|
Sub dd()
Dim r As Long, c As Long, lr As Long, lr2 As Long, lcol As Long, lcol2 As Long
Dim sh As Worksheet, sh1 As Worksheet
Set sh = Worksheets(1)
Set sh2 = Worksheets(2)
Application.ScreenUpdating = False
sh.Range("A:D").Clear
lr = sh2.Cells(Rows.Count, 1).End(xlUp).Row
sh.Cells(1, 1) = sh2.Cells(1, 1)
sh.Cells(1, 3) = sh2.Cells(1, 2)
sh.Cells(1, 4) = sh2.Cells(1, 3)
For r = 2 To lr
lr2 = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
sh.Cells(lr2, 1) = sh2.Cells(r, 1)
sh.Cells(lr2, 3) = sh2.Cells(r, 2)
sh.Cells(lr2, 4) = sh2.Cells(r, 3)
lcol = sh2.Cells(r, Columns.Count).End(xlToLeft).Column
For n = 4 To lcol
If IsNumeric(sh2.Cells(r, n)) Then
lr2 = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
sh.Cells(lr2, 2) = sh2.Cells(r, n)
sh.Cells(lr2, 1) = sh2.Cells(1, n)
sh.Cells(lr2, n).Rows.Group
End If
Next n
Next r
Application.ScreenUpdating = True
End Sub |
А может мне кто-нибудь подсказать, как сделать так, чтобы при группировании сама группа была закрытой (свернутой)? А то они все создаются открытыми