Group

sbaily

Board Regular
Joined
May 13, 2007
Messages
162
hi

I want to be able to group data in excel but automatically
i have in a column A a customer ID and then mutliple rows for different orders, how do i group by the first entry for each customer so i will have one line and when clicking on the + the other orders are displayed?

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi sbaily,

You could just use the "AutoFilter" function to display only those rows for the selected customer ID.

ColinKJ
 
Upvote 0
I was intrigued by this question, put together some code to group some data by running a macro.
Here is my test data:
Excel Workbook
ABCD
1IDcodeDateSalemman
2100001
31112-2027-34/1/2010EMEKA ELENEWOKE (Phc)
49999-1001-14/1/2010EMEKA ELENEWOKE (Phc)
59999-1002-14/1/2010EMEKA ELENEWOKE (Phc)
6100003
79999-1005-14/1/2010EMEKA ELENEWOKE (Phc)
8100034
91101-0022-35/1/2010INNOCENT OGWOGWO (Phc)
101401-0018-25/1/2010INNOCENT OGWOGWO (Phc)
119999-1002-15/1/2010INNOCENT OGWOGWO (Phc)
12100048
131202-0046-36/1/2010DORIS KALIO (Phc)
141402-0040-26/1/2010DORIS KALIO (Phc)
15100065
169999-1002-17/1/2010JOHNNIE AZIBAOLA (Phc)
179999-1005-17/1/2010JOHNNIE AZIBAOLA (Phc)
189999-1006-17/1/2010JOHNNIE AZIBAOLA (Phc)
19100071
201112-2060-37/1/2010SOLOMON IYALLA (Phc)
21100084
221202-0030-38/1/2010INNOCENT OGWOGWO (Phc)
23100085
241112-0100-38/1/2010SPENCER GREEN (Phc)
Sheet
Here is my code.
Code:
Sub AutoGroup()
    Range("B2").Select
    Do Until ActiveCell = "" And ActiveCell.Offset(1, 0) = ""
        If ActiveCell.Offset(0, -1) <> "" Then
            sr = ActiveCell.Offset(1, 0).Row
            Do Until ActiveCell <> "" And ActiveCell.Offset(1, -1) <> ""
                ActiveCell.Offset(1, 0).Activate
                If ActiveCell = "" And ActiveCell.Offset(1, 0) = "" Then GoTo LastGroup
            Loop
            er = ActiveCell.Row
        End If
        Rows(sr & ":" & er).Group
        ActiveSheet.Outline.SummaryRow = xlAbove
        ActiveCell.Offset(1, 0).Activate
        If ActiveCell = "" And ActiveCell.Offset(1, 0) = "" Then Exit Sub
    Loop
LastGroup:
    er = ActiveCell.Offset(-1, 0).Row
    Rows(sr & ":" & er).Group
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
rootytrip

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