Skip to content

Instantly share code, notes, and snippets.

@zafercavdar
Last active January 20, 2022 15:18
Show Gist options
  • Save zafercavdar/80694e9d50d3a999c2ccb3dad889d840 to your computer and use it in GitHub Desktop.
Save zafercavdar/80694e9d50d3a999c2ccb3dad889d840 to your computer and use it in GitHub Desktop.
Sub groupTest()
ActiveSheet.Outline.SummaryRow = xlAbove
Dim sRng As Range
Dim eRng As Range
Dim rng As Range
Dim currRng As Range
Set currRng = Range("B2")
Set sRng = Range("B2")
Do While currRng.Value <> ""
If currRng.Value <> sRng.Value Or currRng.Offset(1).Value = "" Then
If currRng.Offset(1).Value = "" Then
Set eRng = currRng
Else
Set eRng = currRng.Offset(-1)
End If
Set rng = Range(sRng.Offset(1), eRng)
Debug.Print rng.Address
rng.EntireRow.Group
Set sRng = currRng
End If
Set currRng = currRng.Offset(1)
Loop
Debug.Print "done"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment