+ Reply to Thread
Results 1 to 2 of 2

How do I group rows hierarchical (1, 1.1, 1.1.2 ...)

Hybrid View

  1. #1
    Registered User
    Join Date
    06-07-2013
    Location
    Hamburg
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question How do I group rows hierarchical (1, 1.1, 1.1.2 ...)

    I need a macro to group rows in 6 hierarchical levels like:

    1
    1.1
    1.1.1
    1.1.1.1
    1.1.1.1.1
    1.1.1.1.1.1
    1.1.1.1.1.2
    1.1.1.1.1.3
    1.1.2
    1.1.2.1
    1.1.2.1.1
    1.1.2.1.1.1
    1.1.2.1.1.2

    All my attempts didn't work really.
    Any suggestions or tips are appreciated.

    Thanks in anticipation.
    jugeh

  2. #2
    Registered User
    Join Date
    06-07-2013
    Location
    Hamburg
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: How do I group rows hierarchical (1, 1.1, 1.1.2 ...)

    Please Excel experts I ugently need some help.
    This is what I tried but the Code works up to the third level only.

    Sub Grouping_Test()
    Dim Group_Beginn, Group_Ende
    Dim a_Text, n_Text As String
    Dim lastRow As Long
    Dim i, L As Integer
    
    Application.ScreenUpdating = False
    
    Cells.ClearOutline
    Range("A3").Select
    lastRow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
    
    For L = 1 To 6
      i = L + 2
      Do Until i + 1 > lastRow
        a_Text = Mid(Replace(Cells(i, ActiveCell.Column), ".", ""), L, 1)
        n_Text = Mid(Replace(Cells(i + 1, ActiveCell.Column), ".", ""), L, 1)
        
        If a_Text = n_Text Then
          Group_Beginn = Cells(i + 1, ActiveCell.Column).Address
          Do Until (n_Text <> a_Text) Or (i > lastRow) 
            i = i + 1
            n_Text = Mid(Replace(Cells(i, ActiveCell.Column), ".", ""), L, 1)
          Loop
          i = i - 1
          Group_Ende = Cells(i, ActiveCell.Column).Address
          If i >= lastRow Then i = lastRow
          Range(Group_Begin, Group_End).Rows.Group
        End If
         i = i + 1
      Loop
    Next
    
    Application.ScreenUpdating = True
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1