I found a macro that almost gets me what I need and was wondering if someone would help to modify. The macro I have is grouping column A and leaving the first row of each HCode ungrouped. What I need is to group Column A leaving the last (Total) row of each HCode ungrouped:
-- corrupted image removed --
Here's the Macro that needs to be adjust:
Thanks so much for you help.
John
-- corrupted image removed --
Here's the Macro that needs to be adjust:
VBA Code:
Sub GroupRows()
Dim myValue As Variant
Dim myCol As String
Dim myRow As Long
Dim startRow As Long
Dim lastRow As Long
'Which column to look at?
myCol = "A"
'Which row to look at first?
myRow = 2
lastRow = Cells(myRow, myCol).End(xlDown).Row
myValue = Cells(myRow, myCol)
startRow = myRow
Application.ScreenUpdating = False
For i = myRow + 1 To lastRow + 1
If Cells(i, myCol).Value <> myValue Then
'New group begins
Range(startRow + 1 & ":" & i - 1).EntireRow.Group
startRow = i
myValue = Cells(i, myCol).Value
End If
If myValue = "" Then
'blank cell
Exit For
End If
Next i
Application.ScreenUpdating = True
End Sub
Thanks so much for you help.
John
Last edited by a moderator: