我创建了一个创建层次结构的宏。
我希望将这些行的颜色与它们分组的颜色相同,以便获得更好的视觉呈现效果。
答案 0 :(得分:0)
这应该让你入门
Option Explicit
Public Sub highlightGroups() 'if there are no groups it highlights all used rows
Dim lc As Long, ur As Range
With ActiveSheet.UsedRange
lc = .Column + .Columns.Count
.Parent.Outline.ShowLevels RowLevels:=1 '<--- set level
Set ur = .Offset(.Row).Resize(.Rows.Count - 1, lc - 1)
ur.SpecialCells(xlCellTypeVisible).Rows.Interior.Color = vbYellow '<--- set color
'.Parent.Outline.ShowLevels RowLevels:=lc
End With
End Sub