如何将单元格合并为两列以显示同一行中元素之间的所有链接

时间:2019-06-13 18:32:13

标签: google-sheets array-formulas

我正在一个Gephi项目中,我需要定义人(与谁一起工作的人)之间的链接。

我有一个Google表格文档,每行都有名称。 例如:

  • 约翰|玛丽|布赖恩|戴夫
  • 艾米丽|大卫|萨拉

我正在寻找一个函数,该函数可以在两列中显示谁与谁一起工作。这样:

  • 约翰|玛丽
  • 约翰|布莱恩
  • 约翰|戴夫
  • 玛丽|布莱恩
  • 玛丽|戴夫
  • 布莱恩|戴夫
  • 艾米丽|大卫
  • 艾米丽|萨拉
  • 大卫|萨拉

如果您认为Google表格不是问题,并且可以在Excel上进行操作,也可以向我发送建议。

1 个答案:

答案 0 :(得分:0)

如果有人在寻找答案,我今天早上就找到了。

我所要做的就是编辑有关此堆栈溢出问题的代码 Google Sheets - Function to combine cells in a column into two columns with all possible combinations?

更改包含数据的单元格范围(例如,从A1到F1),然后将代码粘贴到新的单元格中。

示例:

=ARRAYFORMULA(SPLIT(SORT(TRANSPOSE(SPLIT(CONCATENATE(REPT(UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),",")))&","& TRANSPOSE(UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",", ,A1:F1)),",")))), ( UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),",")))<= TRANSPOSE(UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),",")))))* REGEXMATCH(CONCATENATE(","&SUBSTITUTE(TEXTJOIN(",",1,A1:F1),",",",,")&","&CHAR(9)),"(,"&  UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),",")))&",[^\t]*,"& TRANSPOSE(UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),","))))&",)|(,"& TRANSPOSE(UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",",1,A1:F1)),","))))&",[^\t]*,"& UNIQUE(TRANSPOSE(SPLIT(JOIN(",",TEXTJOIN(",", ,A1:F1)),",")))&",)"))&CHAR(9)),CHAR(9)))),","))