Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 合并Google工作表中的多个选项卡,并为数据来源添加一列_Arrays_Google Sheets_Google Sheets Formula_Array Formulas_Gs Vlookup - Fatal编程技术网

Arrays 合并Google工作表中的多个选项卡,并为数据来源添加一列

Arrays 合并Google工作表中的多个选项卡,并为数据来源添加一列,arrays,google-sheets,google-sheets-formula,array-formulas,gs-vlookup,Arrays,Google Sheets,Google Sheets Formula,Array Formulas,Gs Vlookup,我有一个电子表格,其中包含多个具有类似布局的选项卡。我想用一个公式把它们合并到一个选项卡中,这个选项卡有一个新的列,命名它来自的选项卡 例子 选项卡:A区 | Item | Status | |------|-------------| | Foo | Blocked | | Bar | In Progress | 选项卡:B区 | Item | Status | |--------|-----------| | Foobar | Completed | 选项

我有一个电子表格,其中包含多个具有类似布局的选项卡。我想用一个公式把它们合并到一个选项卡中,这个选项卡有一个新的列,命名它来自的选项卡

例子 选项卡:A区

| Item | Status      |
|------|-------------|
| Foo  | Blocked     |
| Bar  | In Progress |
选项卡:B区

| Item   | Status    |
|--------|-----------|
| Foobar | Completed |
选项卡:合并

| Area | Item   | Status      |
|------|--------|-------------|
| A    | Foo    | Blocked     |
| A    | Bar    | In Progress |
| B    | Foobar | Completed   |
无新列合并 我可以使用以下公式合并数据,而无需附加列:

=ARRAYFORMULA(SORT({'Area A'!A2:B; 'Area B'!A2:B}))
看起来是这样的:

|--------|-------------|
| Item   | Status      |
|--------|-------------|
| Foo    | Blocked     |
| Bar    | In Progress |
| Foobar | Completed   |
添加区域列 上面的公式缺少的是添加了“面积”列。这可以通过使用vlookup在每个选项卡中交叉引用项目并对其进行标记来实现。但这并不是很有效,而且一些更新在本文档中重新计算时已经很慢了。我预计这将有大约40个标签,共10000行合并

例如:

有更好的方法吗? 我想要这样的东西,但它不起作用,因为我要添加的常量与它需要的行数不匹配:

=ARRAYFORMULA(SORT({{"A",'Area A'!A2:B}; {"B", 'Area B'!A2:B}}))

可以借用空列并执行以下操作:

=ARRAYFORMULA(SORT({{'Area A'!X2:X&"A", 'Area A'!A2:B}; 
                    {'Area B'!X2:X&"B", 'Area B'!A2:B}}))

也可以将其添加到第一列,然后拆分:

=ARRAYFORMULA(QUERY(SORT({SPLIT(
 {"A♦"&'Area A'!A2:A; 
  "B♦"&'Area B'!A2:A}, "♦"), 
 {'Area A'!B2:B; 
  'Area B'!B2:B}}), "where Col2 is not null", 0))
请参阅:

=ARRAYFORMULA(QUERY(SORT({SPLIT(
 {"A♦"&'Area A'!A2:A; 
  "B♦"&'Area B'!A2:A}, "♦"), 
 {'Area A'!B2:B; 
  'Area B'!B2:B}}), "where Col2 is not null", 0))