Concatenate permutations between two columns

前端 未结 4 1631
陌清茗
陌清茗 2021-01-07 06:02

I need help with an excel assignment.

Name    City
---------------
John    London
Maxx    NY
Ashley  DC
        Paris

Solution for this mus

4条回答
  •  孤城傲影
    2021-01-07 06:41

    Here's an Array Formula you can use, though you will need to modify the size of the matrix depending on how many entries you have

    =CONCATENATE(INDEX(A:A,MMULT(ROW(A1:A3),TRANSPOSE(ROW(B1:B4))/TRANSPOSE(ROW(B1:B4)))),"-",INDEX(B:B,MMULT(ROW(A1:A3)/ROW(A1:A3),TRANSPOSE(ROW(B1:B4)))))
    

    Assuming Column A is Names and Column B is Cities, you would select 12 cells (3 rows high, 4 columns wide), paste the above formula in the first cell and press Ctrl + Shift + Enter to create the array formula.

    If you want to see a little simpler version to see what it does before the INDEX references, check with the same area:

    =CONCATENATE(MMULT(ROW(A1:A3),TRANSPOSE(ROW(B1:B4))/TRANSPOSE(ROW(B1:B4))),"-",MMULT(ROW(A1:A3)/ROW(A1:A3),TRANSPOSE(ROW(B1:B4))))
    

    Here's a screenshot (with the formula split in 2 lines) of the single formula displaying the output over multiple cells:

    Excel Array Concatenation

提交回复
热议问题