Hi Everyone,
I'm attempting to reengineer a similar post about grouping columns but I want to group rows. Below is the original thread with an excellent response from @Crystalyzer:
Group by Column Thread
What I want to do is group rows of sub-accounts within a parent subtotal row and Grand Total. Below is what I would like the final output to look like. Starting point is identical without the groups.
This is the current code I have so far that loops through the rows and appears to identify the correct Subtotal rows but doesn't group the rows. I appreciate any help. Thank you to @Crystalyzer for getting me this far.
Thanks in advance for any input!!
I'm attempting to reengineer a similar post about grouping columns but I want to group rows. Below is the original thread with an excellent response from @Crystalyzer:
Group by Column Thread
What I want to do is group rows of sub-accounts within a parent subtotal row and Grand Total. Below is what I would like the final output to look like. Starting point is identical without the groups.
This is the current code I have so far that loops through the rows and appears to identify the correct Subtotal rows but doesn't group the rows. I appreciate any help. Thank you to @Crystalyzer for getting me this far.
Code:
Sub GroupRows()
Dim i As Long, grpRowStart As Long, grpRowEnd As Long
Dim strtRow As Long, endRow As Long
If Range("B2") = "" Then
strtRow = Range("B2").End(xlDown)
Else
strtRow = 1
End If
endCol = Cells(Rows.Count, "B").End(xlUp).Row
For i = strtRow To endRow
If InStr(2, Cells(i, 2), "F_6") = 0 Then
If grpRowStart = 0 Then grpRowStart = i
grpRowEnd = i
Else
If grpRowStart <> 0 And grpRowEnd <> 0 Then
Range(Cells(grpRowStart, 2), Cells(grpRowEnd, 2)).Rows.Group
grpRowStart = 0
grpRowEnd = 0
End If
End If
Next
End Sub
Thanks in advance for any input!!