收集所有工作表中的数据的方法:

huangapple go评论53阅读模式
英文:

SpreadSheet - how to collect all the data from each sheet

问题

因为我目前在我的公式中遇到了问题,所以我联系你...
这是背景:

我有一个包含6个工作表的电子表格,在第6个工作表中,我需要一个公式来查找其他工作表中的每个“ok”。

当第1、2、3工作表的H列等于“ok”时,我想要获取第1、2、3工作表的A、B、C、D列。
当第4工作表的I列等于“ok”时,我想要获取第4工作表的A、B、C、E列。
当第5工作表的J列等于“ok”时,我想要获取第5工作表的A、B、C、D列。

示例:如果在第1工作表中有2行包含ok,第2工作表中有1行包含ok,第4工作表中有2行包含ok,第5工作表中有1行包含ok,那么结果应该在第6工作表中如下:

a b c d (第1工作表)
a b c d (第1工作表)
a b c d (第2工作表)
a b c e (第4工作表)
a b c e (第4工作表)
a b c d (第5工作表)

我尝试使用以下公式:

=QUERY({'Sheet1'!A:J;'Sheet2'!A:J;'Sheet3'!A:J;'Sheet4'!A:J;'Sheet5'!A:J},"select Col1, Col2, Col3, Col4 where Col10 = 'ok' OR Col9 = 'ok' OR Col8 = 'ok'",0)

这个公式在工作表1、2、3上工作,因为它们具有相同的结构...但我不知道如何处理工作表4和5的特殊情况。

提前感谢你的帮助,希望这很清楚^^

英文:

I contact you because I am currently blocked with my formula...
here is the context :

i've a spreadsheet with 6 sheets, in sheet6 i need a formula to find each "ok" in the others sheets

i want to get colunm a b c d for sheets 1 2 3 when colunm h equal "ok"
i want to get colunm a b c e for sheet 4 when colunm i equal "ok"
i want to get colunm a b c d for sheet 5 when colum j equal "ok"

Example : if i've 2 lines with ok in sheet1, 1 line with ok in sheet2, 2 lines in ok in sheet 4 and 1 line with ok in sheet 5, result must to be in sheet 6 :

a b c d (sheet1)
a b c d (sheet1)
a b c d (sheet2)
a b c e (sheet4)
a b c e (sheet4)
a b c d (sheet5)

I tried to use :

=QUERY({'Sheet1'!A:J;'Sheet2'!A:J;'Sheet3'!A:J;'Sheet4'!A:J;'Sheet5'!A:J},"select Col1, Col2, Col3, Col4 where Col10 = 'ok' OR Col9 = 'ok' OR Col8 = 'ok'",0)

it's work with sheet 1 2 3 because same structuration... but i don't know exactly how to manage the specific for sheet 4 and 5

thx in advance for ur help
i hope that is clear ^^

答案1

得分: 1

你可以尝试堆叠每张表的“result”列和每张表的“search”列:

=QUERY({Sheet1!A:D,Sheet1!H:H;Sheet2!A:D,Sheet2!H:H;Sheet3!A:D,Sheet3!H:H;Sheet4!A:C,Sheet4!E:E,Sheet4!I:I;Sheet5!A:D,Sheet5!J:J},"选择 Col1,Col2,Col3,Col4 where Col5 = 'ok'",)

这样,您创建了一个包含5列的范围,其中有4列用于结果,最后一列用于查找“OK”。


更新

我已将其更新为您的区域设置和实际表格名称:

`=QUERY({'Feuille 1'!A:D'Feuille 1'!H:H;'Feuille 2'!A:D'Feuille 2'!H:H;'Feuille 3'!A:D'Feuille 3'!H:H;'Feuille 4'!A:C'Feuille 4'!E:E'Feuille 4'!I:I;'Feuille 5'!A:D'Feuille 5'!J:J},"选择 Col1,Col2,Col3,Col4 where Col5 = 'OK';")

英文:

You can try stacking the for "result" columns from each sheets, and the for "search" columns from each sheet:

=QUERY({Sheet1!A:D,Sheet1!H:H;Sheet2!A:D,Sheet2!H:H;Sheet3!A:D,Sheet3!H:H;Sheet4!A:C,Sheet4!E:E,Sheet4!I:I;Sheet5!A:D,Sheet5!J:J},"Select Col1,Col2,Col3,Col4 where Col5 = 'ok'",)

This way, you're creating a range with 5 columns, 4 for the result and 1 last one for looking the "OK"


UPDATE

I've updated it to your locale and actual names of sheets:

=QUERY({'Feuille 1'!A:D\'Feuille 1'!H:H;'Feuille 2'!A:D\'Feuille 2'!H:H;'Feuille 3'!A:D\'Feuille 3'!H:H;'Feuille 4'!A:C\'Feuille 4'!E:E\'Feuille 4'!I:I;'Feuille 5'!A:D\'Feuille 5'!J:J};"Select Col1,Col2,Col3,Col4 where Col5 = 'OK'";)

收集所有工作表中的数据的方法:

答案2

得分: 0

我能使它正常工作的唯一方法是使用以下公式:

={QUERY({'Feuille 1'!A:J;'Feuille 2'!A:J;'Feuille 3'!A:J};
    "select Col1,Col2,Col3,Col4 where Col8 = 'OK'";0);
  QUERY('Feuille 4'!A1:I;"Select A, B, C, E where I = 'OK'";0);
  QUERY('Feuille 5'!A1:J;"Select A, B, C, D where J = 'OK'";0)}

由于您要从“Sheet 4”获取的列不同,这会导致查询中断,并且无法正确导入行,这也会破坏“Sheet 5”,它返回与前三个表相同的模式。

最后,它将看起来像您期望的结果:

收集所有工作表中的数据的方法:

英文:

The only way I could make it work is using the following formula:

={QUERY({'Feuille 1'!A:J;'Feuille 2'!A:J;'Feuille 3'!A:J};
    "select Col1,Col2,Col3,Col4 where Col8 = 'OK'";0);
  QUERY('Feuille 4'!A1:I;"Select A, B, C, E where I = 'OK'";0);
  QUERY('Feuille 5'!A1:J;"Select A, B, C, D where J = 'OK'";0)}

Since the columns that you want from the Sheet 4 are different, this break the query and doesn't import the rows correctly, this also breaks the Sheet 5 which returns to the same patter of the first 3 sheets.

At the end, it will look like your expected result:

收集所有工作表中的数据的方法:

huangapple
  • 本文由 发表于 2023年7月17日 17:06:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76702947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定