Grouping of Rows

akul2013

New Member
Joined
May 7, 2014
Messages
2
Hello Every one,

I have data with duplicated values in a column and I would like to group the rows where there are duplicates entered i.e. the data is as follows :

Emp1
Emp1
Emp1
Emp2
Emp2
Emp2
Emp3
Emp3
Emp3

The output which I would like to see is :

+Emp1
+Emp2
+Emp3

When I click on the + sign it should expand.

I have tried with Grouping of rows and subtotal, these does not serve the purpose.

Request you to help me in this regards.
 
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 = 1
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
 
Upvote 0
Thank you so much for the VBA script Chetan. However, wanted to know, if there is a feasibility using Excel options with out any VBA Script
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top