Forum Discussion
Merge Data From Two Sheets in Same Workbook and Sort
- Jul 05, 2021
I don't know how exactly your data is structured, for that better to have sample file. Assume you have two structured tables, they could be in different sheets. If ranges, you may convert them to tables by Ctrl+T or use named ranges. Something like this
To join these tables you may use formula as
=LET( rowsOne, ROWS(Table1), rowsTwo, ROWS(Table2), c, SEQUENCE(,COLUMNS(Table1)), hMerge, LET( k, SEQUENCE(rowsOne+rowsTwo), IF(k<=rowsOne, INDEX(Table1, k, c), INDEX(Table2, k-rowsOne, c)) ), SORT(hMerge) )
and instead of Table1, Table2 use names of your actual tables or ranges.
If your version of Excel supports dynamic arrays that could be done using them. Especially if you organize your data as structured tables.
- SergeiBaklanJul 05, 2021Diamond Contributor
Please check if this LET function - Office Support (microsoft.com) available.
- JosephA1915Jul 05, 2021Copper Contributor
- SergeiBaklanJul 05, 2021Diamond Contributor
I don't know how exactly your data is structured, for that better to have sample file. Assume you have two structured tables, they could be in different sheets. If ranges, you may convert them to tables by Ctrl+T or use named ranges. Something like this
To join these tables you may use formula as
=LET( rowsOne, ROWS(Table1), rowsTwo, ROWS(Table2), c, SEQUENCE(,COLUMNS(Table1)), hMerge, LET( k, SEQUENCE(rowsOne+rowsTwo), IF(k<=rowsOne, INDEX(Table1, k, c), INDEX(Table2, k-rowsOne, c)) ), SORT(hMerge) )
and instead of Table1, Table2 use names of your actual tables or ranges.