View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
keiji kounoike keiji kounoike is offline
external usenet poster
 
Posts: 199
Default Grouping According to IndentLevel

I don't understand what you are doing, but this code works without error
in my side. if rows are arranged to IndentLevel, the result would be messed.

Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And Range("B" & lngRow).IndentLevel = (i) Then
Range("B" & lngRow).Rows.Group
End If
Next lngRow
Next i
End Sub

Keiji

ryguy7272 wrote:
Thanks again Eric. Did that work for you? Still can't get this working.
This is what I have now:

Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If ActiveSheet.Range("B" & lngRow) < "" And ActiveCell.IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i
End Sub

Maybe the Cells are not being properly selected...
Any more ideas?