Is there a constraint on the depth level of grouping in Excel?

I am trying to write a macro in Excel which will allow me to automatically do groupings based on the number located in the first column. Here is the code.

Sub Makro1()
Dim maxRow As Integer
Dim row As Integer
Dim groupRow As Integer
Dim depth As Integer
Dim currentDepth As Integer

maxRow = Range("A65536").End(xlUp).row

For row = 1 To maxRow
    depth = Cells(row, 1).Value
    groupRow = row + 1
    currentDepth = Cells(groupRow, 1).Value
    If depth >= currentDepth Then
       GoTo EndForLoop
    End If
    Do While currentDepth > depth And groupRow <= maxRow
        groupRow = groupRow + 1
        currentDepth = Cells(groupRow, 1).Value
    Loop
    Rows(row + 1 & ":" & groupRow - 1).Select
    Selection.Rows.Group
EndForLoop:
    Next row
End Sub

The first column in the Excel file looks like this:

1
2
2
3
3
4
4
4
4
5
5
5
6
6
6
6
5
6
6
6
7
8
8
9
10
9
10
10
8
7
7
8
6
5
4
3
2
1
2

When the macro reaches the depth 8 speaking of the groupings, I get error number 1004. It looks like the Excel does not allow me to create a depth greater than 8. Is there a workaround for this? I am using MS Excel 2003.

Answers


You are out of luck.

There is an 8 level limit for grouping which

  • also exists in xl07
  • on my testing exists in xl2010 (gives "Group method of range class failed")

Need Your Help

How to add border to paragraph in itext pdf library in java?

java itext

I have created a paragraph in using itext pdf library in java. I have to add border to paragraph, not to the whole document. How to do it ?

Inheriting AppCompat 22.1.1 Dialog colorAccent from app theme doesn't work

android android-support-library android-styles appcompat-v7-r22.1

I'm trying to set up AppCompat's Dialogs so that the buttons use the same color as the application's accent color, without repeating the color itself. This was working perfectly with AppCompat v22 ...