Rajinder Sharma
New Member
I want grouping data of column D basis start row i.e row no 7 non blank till last row non blank -1. Also i have to repeat this activity in column c then B & then A.
Basis below code successfully able to group C & B but wherever turns to column A wherein from A7 to A325 are non blank cell. From A7 at some interval cell contains Total From total till above i.e A7 which i want to group.
Please help. thanks in advance
>> ! Use code-tags ! <<
Basis below code successfully able to group C & B but wherever turns to column A wherein from A7 to A325 are non blank cell. From A7 at some interval cell contains Total From total till above i.e A7 which i want to group.
Please help. thanks in advance
>> ! Use code-tags ! <<
Code:
Sub Grup()
Dim row As Long
Dim col As String
Dim start_row As Long
Dim i As Long, counter As Long
'Input the beginning row
start_row = 7
'Input the Column name
col = "c"
counter = 0
row = ActiveSheet.Cells.Find(What:="*", After:=Cells(Cells.Rows.Count, Cells.Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
For i = start_row + 1 To row
If Cells(i, col).Value = Cells(i - 1, col).Value Then
Cells(i, col).EntireRow.Group
If counter = 0 Then
Cells(i - 1, col).EntireRow.Group
counter = counter + 1
Else: End If
Else
counter = 0
End If
Next i
'Input the beginning row
start_row = 7
'Input the Column name
col = "B"
counter = 0
row = ActiveSheet.Cells.Find(What:="*", After:=Cells(Cells.Rows.Count, Cells.Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
For i = start_row + 1 To row
If Cells(i, col).Value = Cells(i - 1, col).Value Then
Cells(i, col).EntireRow.Group
If counter = 0 Then
Cells(i - 1, col).EntireRow.Group
counter = counter + 1
Else: End If
Else
counter = 0
End If
Next i
Last edited by a moderator: