Public Function tester()
Dim iam As Long
Dim jam
Dim p1, p2, p3, p4, p5, p6, p7 As Integer
iam = Range("K" & Rows.Count).End(xlUp).Row
For jam = 7 To iam
If Cells(jam, 11) = "2" Then
p1 = Cells(jam - 1, 11) '............last 1's
Else
If Cells(jam, 11) = "3" Then
p2 = Cells(jam - 1, 11) '............last 2's
Else
If Cells(jam, 11) = "4" Then
p3 = Cells(jam - 1, 11) '............last 3's
Else
If Cells(jam, 11) = "5" Then
p4 = Cells(jam - 1, 11) '............last 4's
Else
If Cells(jam, 11) = "6" Then
p5 = Cells(jam - 1, 11) '............last 5's
Else
If Cells(jam, 11) = "7" Then
p6 = Cells(jam - 1, 11) '............last 6's
Else
If Cells(jam, 11) = "" Then
p7 = Cells(jam - 1, 11) '............last 7's
End If
End If
End If
End If
End If
End If
End If
Next
'Range(Cells(7, 11), Cells(p1, 11)).Select 'will group 1 no.
'Selection.Rows.Group
Rows("7:" & p1).Group
Range(Cells(p1 + 1, 11), Cells(p2, 11)).Select 'will group 2 no.
Selection.Rows.Group
Range(Cells(p2 + 1, 11), Cells(p3, 11)).Select 'will group 3 no.
Selection.Rows.Group
Range(Cells(p3 + 1, 11), Cells(p4, 11)).Select 'will group 4 no.
Selection.Rows.Group
Range(Cells(p4 + 1, 11), Cells(p5, 11)).Select 'will group 5 no.
Selection.Rows.Group
Range(Cells(p5 + 1, 11), Cells(p6, 11)).Select 'will group 6 no.
Selection.Rows.Group
Range(Cells(p6 + 1, 11), Cells(p7, 11)).Select 'will group 7 no.
Selection.Rows.Group
End Function