I have created a macro which creates a hierarchy.
I want to color the rows at same level as they are grouped in order to have a better visual presentation.
I have created a macro which creates a hierarchy.
I want to color the rows at same level as they are grouped in order to have a better visual presentation.
This should get you started
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