VBA code to group entire rows based on column A’s cell content and add the group columns

I need to group rows based on repeated text cell in column A , no. of columns are dynamic

then sum total of each group and hide the groups showing only the totals

 

Thanks,

Raghu

 

Top Contributor Asked 6 days ago in VBA.
Add Comment
1 Answer(s)

As start point try this code

Sub Group()
Dim AsteriskPositions(1 To 1500) As Long
Dim counter As Long, I As Long
For I = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Cells(I, 1).Value <> Cells(I + 1, 1).Value Then
counter = counter + 1
AsteriskPositions(counter) = Cells(I, 1).Row
End If
Next I
For I = 1 To counter
If I = counter Then
Exit Sub
Else
Range("A" & AsteriskPositions(I) + 1 & ":A" & AsteriskPositions(I + 1) - 1).Rows.Group
End If
Next I
End Sub

Can you show us sample of your workbook to see what we can do with totals?

Expert Answered 6 days ago.

Thanks for the assistance, tried with above code, its  grouping only for few texts not for all the unique texts in Column A, there are more than 3000 rows, month on month it keeps increasing.

Also let me know where to send the sample workbook attachments??? any email ID??

thanks,

Raghu

5 days ago.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.