我正在尝试对在某些单元格中具有某些缩进的行进行分组。例如,我想在下面的屏幕截图中将第12和13行,第14和15行,第15至27行分组:
我试图编写代码,但显然不起作用,有人可以帮忙解决它吗? 谢谢!
Sub autogroup()
Dim c As Range
Dim rng0 As Range
Dim block As Range
Set block = Range("c12:c179")
For Each c In block
If Not IsEmpty(c) And Left(c.Select, 10) = " " Then
If rng0 Is Nothing Then
Set rng0 = c
Else
Set rng0 = Union(rng0, c)
End If
End If
If Not Left(c.Select, 10) = " " Then
Set rng0 = Union(rng0, c)
End If
Next c
For Each c In rng0.Areas
c.EntireRow.Group
Next c
End Sub