hello
i have a sheet with data which follows the following format :
1 Top level
2 Level 2 line
3 Level 3 line
3 Level 3 line
2 Level 2 line
3 Level 3 line
3 Level 3 line
4 Level 4 line
the number of lines per level is variable
What I would like is for the grouping to occur in the following way
+ 1 Top level
| +2 Level 2 line
| | 3 Level 3 line
| | 3 Level 3 line
| -
| +2 Level 2 line
| |3 Level 3 line
| |3 Level 3 line
| -
-
any ideas ?
this is how it is now, but it does not give appropriate grouping
i have a sheet with data which follows the following format :
1 Top level
2 Level 2 line
3 Level 3 line
3 Level 3 line
2 Level 2 line
3 Level 3 line
3 Level 3 line
4 Level 4 line
the number of lines per level is variable
What I would like is for the grouping to occur in the following way
+ 1 Top level
| +2 Level 2 line
| | 3 Level 3 line
| | 3 Level 3 line
| -
| +2 Level 2 line
| |3 Level 3 line
| |3 Level 3 line
| -
-
any ideas ?
this is how it is now, but it does not give appropriate grouping
Code:
Sub doOutline(hierarchyDepth As Integer, lastRow As Long, objSheet As Worksheet, objApp As Excel.Application)
Dim currentlevel As Long
Dim ix As Long
Dim topRow As Long
Dim bottomrow As Long
If hierarchyDepth > 0 Then
For currentlevel = 1 To hierarchyDepth - 1 'number of groups
ix = lastRow
bottomrow = lastRow
Do While ix > 3
Do While Val(objSheet.Cells(ix, 1)) > currentlevel
ix = ix - 1
Loop
topRow = ix + 1
If bottomrow >= topRow Then
objSheet.Activate
objSheet.Rows(Format(topRow) & ":" & Format(bottomrow)).Select
objApp.Selection.Rows.Group
End If
ix = ix - 1
bottomrow = ix
Loop
Next currentlevel
End If
End Sub