Оптимизированный код, весь модуль.
Время работы 3:55 на 25921 строках. Excel 2007, 2.8 ГГц
Option Explicit
Const SCND As Double = 1 / 24 / 3600
Sub GroupMulti()
Dim a As Range, c1 As Range, c2 As Range, i As Integer, t As Double, t0 As Date
Application.ScreenUpdating = False
t0 = Now
t = t0
For i = 4 To 1 Step -1
For Each a In Columns(i).SpecialCells(xlCellTypeBlanks).Areas
If Now - t > SCND Then
t = Now
Application.StatusBar = "Уровень: " & i & " строка: " & a.Row
End If
Set c2 = Nothing
For Each c1 In a.Cells
If Range(Cells(c1.Row, 1), c1).Text = "" Then
If c2 Is Nothing Then Set c2 = c1 Else Set c2 = Union(c2, c1)
End If
Next
If Not c2 Is Nothing Then c2.Rows.Group
Next
ActiveSheet.Outline.ShowLevels RowLevels:=1
Next
Application.ScreenUpdating = True
Application.StatusBar = False
MsgBox "Время работы " & Format(Now - t0, "hh:mm:ss")
End Sub
Sub RemoveGrouping()
Cells.RemoveSubtotal
End Sub