Create list of last(family) names when parents have children in more than 1 class

Hart

Board Regular
Joined
Jan 2, 2005
Messages
76
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
MASTER CLASS LIST Nov 12 2024.xlsm
BCDEFGHILMN
1Last NameFirst NameDOBGenderPhoneParentsPHNAddressNamePENGrade
Families


I would like to create a sheet containing the last (family) name of all students in a school as well the grade. The family name will appear in ColumnA and the Grade in ColumnB. Additionally, a family may have more than 1 student in a class (twins or triplets) and if so, the resulting grade cell would also include the number of children in the grade, for example 5(2x) twins or 5(3x) triplets etc. The information is contained in a table (above). The determining factor when there are multiple identical last names is the "contact field" contents - i.e. same parent/guardian. The table can be sorted in any sequence but will likely be by last name, contact and grade. Ideally, after 55 (or so) family names and grades, the macro will then start populating at row 1, columns D and E, Then Columns G and H. After G and H are filled, back to column a&B with a page break. Continue until the table is processed.

Resulting output sheet called "families":
ColumnA ColumnB
Name Grade

Anderson 3
Brown 3 x 2, 4, 5 (for 2 students in grade 3) one in grade 4, one in grade 5
etc.....
Many thanks in advance,
Hart
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
As you are using (also) Microsoft 365 - have you been thinking of a new function GroupBy ? Something like:
Excel Formula:
=GROUPBY(HSTACK(Table1[[#All],[Last Name]],Table1[[#All],[Parents]]),Table1[[#All],[Grade]],ARRAYTOTEXT,3,0)

Well, it does not list Anderson as 3x2; 4 , just simple 3; 3; 4 but may be it would be enough? If not lambda function could be used instead of ARRAYTOTEXT
PS. in your case the output can be with commas not semicolons - it depends on system local settings.

I used HSTACK inside, because there are 2 Scott families in my school :-)
Zeszyt1
ABCDEFGHIJKLMNOPQR
1Last NameFirst NameDOBGenderPhoneParentsPHNAddressColumn1Column2NamePENGradeLast NameParentsGrade
2AndersonPeterMaria, John3AndersonMaria, John3; 3; 4
3AndersonAnneMaria, John3BrownAnna, Peter3
4AndersonIanMaria, John4ScottMaria, Jack4; 5
5BrownKevinAnna, Peter3ScottMaria, John6
6ScottLilyMaria, Jack4
7ScottPeterMaria, Jack5
8ScottPeterMaria, John6
9
Arkusz1
Cell Formulas
RangeFormula
O1:Q5O1=GROUPBY(HSTACK(Table1[[#All],[Last Name]],Table1[[#All],[Parents]]),Table1[[#All],[Grade]],ARRAYTOTEXT,3,0)
Dynamic array formulas.
 
Upvote 0
Solution
As you are using (also) Microsoft 365 - have you been thinking of a new function GroupBy ? Something like:
Excel Formula:
=GROUPBY(HSTACK(Table1[[#All],[Last Name]],Table1[[#All],[Parents]]),Table1[[#All],[Grade]],ARRAYTOTEXT,3,0)

Well, it does not list Anderson as 3x2; 4 , just simple 3; 3; 4 but may be it would be enough? If not lambda function could be used instead of ARRAYTOTEXT
PS. in your case the output can be with commas not semicolons - it depends on system local settings.

I used HSTACK inside, because there are 2 Scott families in my school :-)
Zeszyt1
ABCDEFGHIJKLMNOPQR
1Last NameFirst NameDOBGenderPhoneParentsPHNAddressColumn1Column2NamePENGradeLast NameParentsGrade
2AndersonPeterMaria, John3AndersonMaria, John3; 3; 4
3AndersonAnneMaria, John3BrownAnna, Peter3
4AndersonIanMaria, John4ScottMaria, Jack4; 5
5BrownKevinAnna, Peter3ScottMaria, John6
6ScottLilyMaria, Jack4
7ScottPeterMaria, Jack5
8ScottPeterMaria, John6
9
Arkusz1
Cell Formulas
RangeFormula
O1:Q5O1=GROUPBY(HSTACK(Table1[[#All],[Last Name]],Table1[[#All],[Parents]]),Table1[[#All],[Grade]],ARRAYTOTEXT,3,0)
Dynamic array formulas.
I haven't even looked at the groupby function but will now. This is perfect. Thanks!
 
Upvote 0
If you are not going to be moving the columns around then you could compact that a bit.
I am assuming 'Last Name' is the 1st column in the table and 'Parents' is the 6th column. Adjust the 1, 6 in the formula if that is not correct.
Excel Formula:
=GROUPBY(CHOOSECOLS(Table1[#All],1,6),Table1[[#All],[Grade]],ARRAYTOTEXT,3,0)
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,544
Latest member
aush

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