-1

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.

Community
  • 1
  • 1
  • Perhaps [this](http://stackoverflow.com/questions/21280803/using-vba-to-apply-conditional-formatting-to-a-range-of-cells) might help you. – il_raffa Sep 25 '15 at 07:45
  • 1
    Welcome to Stack Overflow. It would be worth posting the code you have already attempted and what's going wrong. That's more likely to bring you a good answer. – Trum Sep 25 '15 at 07:56

1 Answers1

0

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
paul bica
  • 10,557
  • 4
  • 23
  • 42