Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community


Copper Contributor


I’m trying to sort these columns by name but I need the lines for each employee to stay with their associated employee.   For example Caleb smith is employee number 1 and the three lines above him are associated with him so if I were to sort alphabetically it throws it off into a weird order.   Any help to get this sorted would be much appreciated!

5 Replies


In a custom sort, you could sort on employee number first, then on material (or another column).

That will keep the rows for each employee together.

However this will not alphabetize the employees right?


No, the layout is not suitable for that.

need the lines for each employee to stay with their associated employee.??

Can you share your file with dummy data and expected result?

@LeeWhitt23 How about adding a calculated column to the table for the employee name? With the help of a separate employee lookup table, you could use the XLOOKUP function to accomplish this. For example:


=XLOOKUP([@[EMP'#/LOCK'#]], tblEmployees[ID], tblEmployees[NAME])


Then sort the table by the calculated "NAME" column from A to Z:


Sort by Lookup ColumnSort by Lookup Column


Note: if the XLOOKUP function is not available in your version of Excel, use the INDEX / MATCH equivalent:


=INDEX(tblEmployees[NAME], MATCH([@[EMP'#/LOCK'#]], tblEmployees[ID], 0))


Please see the attached sample workbook...