导入范围和查询导入顺序是随机的且不低于彼此

发布于 2025-01-13 19:41:13 字数 2456 浏览 0 评论 0原文

我有一些问题,我有一段时间试图解决这个问题,但我总是陷入死胡同。

我的数据表中有多次点击,每次点击都有5000 多行(在本例中现在少得多),有些行有相同的内容,并且我想在我的 ArtikleFinder 表中查找特定行, 同时输入特定号码和匹配号码复制与不同工作表 B 匹配的那些行,并保留工作表 A 中的格式等。

示例:我需要制作发货/订单列表,我有 2 张工作表 A 充满了信息(我的库存),将选项卡与每个选项卡中有很多行。在工作表 B(新 URL)中我想过滤信息。

比方说,我有 5000 篇文章分布在工作表 A 的 5 个选项卡中,有人订购了 20 篇文章,所以我只想将特定数量或任何其他条件扫描到工作表 B,并且包含该数据的所有行都将被导入。现在我有了一个全新的列表,只有 20 篇文章,我可以将其分享给客户。

到目前为止,我通过 Importrange 和查询解决了这个问题,但它是有限的。我只能在 1 个查询中搜索 3 个条件,而且数据是随机出现的。

我必须制作 2 个选项卡 &具有 2 个不同查询但相同导入范围的代码能够找到所有匹配的数据。

PKG-ID 和BOL 查找器(第 2 列和第 3 列)

=QUERY({
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 17.02. - 20.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 21.02 - 27.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 28.02 - 06.03!A:J")
}, "WHERE Col2 = '"&TEXTJOIN("' OR Col2 = '", TRUE, A:A)&"' OR Col3 like '"&TEXTJOIN("' OR Col3 like '", TRUE, A:A)&"'", 0)

ASIN、EAN、LPN 查找器(第 5 - 6 - 7 列)

注意:LPN(Col7) 需要包含而不是 LIKE,因为我一个单元格中通常有多个 LPN 编号,否则无法找到

=QUERY({
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 17.02. - 20.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 21.02 - 27.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 28.02 - 06.03!A:J")
}, "WHERE Col5 = '"&TEXTJOIN("' OR Col5 = '", TRUE, A:A)&"' OR Col6 like '"&TEXTJOIN("' OR Col6 like '", TRUE, A:A)&"' OR Col7 contains '"&TEXTJOIN("' OR Col7 contains '", TRUE, A:A)&"'", 0)

。我无法弄清楚以下内容:

  1. 扫描 PKG-ID(例如)时,会出现文章。在下一次扫描中,该文章也会出现,但会出现在下方、上方或中间。我希望所有内容都显示在彼此下方,这样我就不必搜索新的扫描来查看该数字的含义。

  2. 我宁愿只点击一次而不是两次进行扫描。但查询似乎受到限制,有解决方法吗?

  3. 如果导入范围会自动看到包含所有选项卡的整个工作表,而不是为每个选项卡我必须放置一个新的“导入范围”,那么导入范围也会更容易工作

  4. 与此解决方案相关的新的“导入范围”

    ,我还需要另一个选项,其中仅导入特定行,这也可以通过查询来解决,我只是想知道是否也可以将其与上面的问题结合起来?,“select Col1,Col2,Col6,Col7,Col8,Col15,Col16,Col17 其中 Col2 匹配 '"&TEXTJOIN("|", 1, A2:A)&"'", 0)

导入范围/查询中是否可能只缺少一些数字?

谢谢

I have some problems, I am trying to resolve this now since a while but I am always ad a dead end.

I have multiply taps in my DATA Sheet, each tap has 5000+ rows (in this example now way less), some rows have the same content and I want to find specific rows in my ArtikleFinder Sheet, while entering a specific number and the matching numbers copy those rows which are matching to a different sheet B and keep the formatting etc from sheet A.

Example: I need to make a shipping/order list I have 2 sheets Sheet A is full of information (my stockload), multiply tabs with a lot of rows in each tab. in Sheet B (new URL) I want to filter the information.

Let's say, I have 5000 articles spread in 5 tabs on Sheet A, someone is ordering 20 articles, so I just want to scan the a certain number or any other criteria to Sheet B, and all rows with that data, will be imported. Now I have a brand new list with only the 20 articles, which I can share to the client.

Till now I resolved this with Importrange and query, however it is limited. I can only search for 3 criteria within 1 query, and also the data appears randomly.

I had to make 2 tabs & codes with 2 different query but same Importrange to be able to find all the matching data.

PKG-ID & BOL Finder (Column 2 & 3)

=QUERY({
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 17.02. - 20.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 21.02 - 27.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 28.02 - 06.03!A:J")
}, "WHERE Col2 = '"&TEXTJOIN("' OR Col2 = '", TRUE, A:A)&"' OR Col3 like '"&TEXTJOIN("' OR Col3 like '", TRUE, A:A)&"'", 0)

ASIN, EAN, LPN Finder (Column 5 - 6 - 7)

NOTE: LPN(Col7) needs to be CONTAINS and not LIKE, since I often have multiple LPN numbers in one cell and it cant be found otherwise

=QUERY({
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 17.02. - 20.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 21.02 - 27.02!A:J");
IMPORTRANGE("1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI", "MERGE 28.02 - 06.03!A:J")
}, "WHERE Col5 = '"&TEXTJOIN("' OR Col5 = '", TRUE, A:A)&"' OR Col6 like '"&TEXTJOIN("' OR Col6 like '", TRUE, A:A)&"' OR Col7 contains '"&TEXTJOIN("' OR Col7 contains '", TRUE, A:A)&"'", 0)

What I can't figure out are the following things:

  1. When scanning the PKG-ID (for example), the Article appears. In the next scan, the article appears as well BUT either below, above or in the middle. I want everything to appear below each other, so I don't have to search the new scan to see, what the number is all about.

  2. I would prefer to only have one tap instead of two for the scans. But Query seems to be limited, is there a workaround?

  3. Importrange would also work easier if It see's automatically the whole sheet with all the tabs instead for each tab I have to put a new "Importrange"

  4. related to this solution, I also need another option, where only specific rows will be imported, this also can be solved with query, I just would like to know If I can combine this with the problems above too?, "select Col1,Col2,Col6,Col7,Col8,Col15,Col16,Col17 where Col2 matches '"&TEXTJOIN("|", 1, A2:A)&"'", 0)

Is there maybe only a some numbers I am missing with Importrange/Query?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋意浓 2025-01-20 19:41:13

#1

对于问题 n°1,由于 importrange 和 query 将采用数据库的顺序,因此很难在本次扫描和查询结果之间获得相同的顺序。

我还希望之前的扫描已经拾取了一些行。

的公式来顶级条件格式

=A1=index($A:$A,match("zzz",$A:$A,1))

如果您想突出显示输入的最后一次扫描,您可以做的是使用类似 在此处输入图像描述

#3

为了帮助您在公式中添加新选项卡,您可以通过小脚本,例如PKG-ID,BOL:

function myFunction() {
  var id = '1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI'
  var ss = SpreadsheetApp.openById(id)
  var rng = []
  ss.getSheets().forEach(sh => rng.push(`IMPORTRANGE("${id}", "${sh.getName()}!A:J")`))
  var formula = `=QUERY({${rng.join(';')}}, "WHERE Col2 = '"&TEXTJOIN("' OR Col2 = '", TRUE, A:A)&"' OR Col3 like '"&TEXTJOIN("' OR Col3 like '", TRUE, A:A)&"'", 0)`
  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('PKG-ID, BOL').getRange('B3').setFormula(formula)
}

编辑

通过脚本

function artikleFinder() {
  var id = '1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI'
  var source = SpreadsheetApp.openById(id)
  var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('TEST (script)')
  sh.getRange(3,2,sh.getLastRow(),sh.getLastColumn()).clearContent()
  var list = sh.getRange('A3:A').getValues().filter(r => r[0] != '').join().split(',')
  var data = []
  list.forEach(function (crit) {
    source.getSheets().forEach(function (sh) {
      var blankRow = Array.from({ length: 1 }, () => Array.from({ length: 10 }, () => ''))
      var prov = sh.getRange(1,1,sh.getLastRow(),10).getValues().filter(
        r => (r[1] == crit || r[2] == crit || r[4] == crit || r[5] == crit || r[6] == crit)
      )
      if (prov.length){
        data.push(prov)
        data.push(blankRow)
      }
    })
  })
  result = data.flat()
  sh.getRange(3,2,result.length,result[0].length).setValues(result)
}

结果将与 A 列中的列表顺序相同。但是,如果一行匹配不同的条件,则该行将被重复

#1

For question n°1, it will be difficult to obtain the same order between this scan and the result of the query since importrange and query will take the order of the database.

I also expect some rows to have already been picked up by a previous scan.

What you can do if you want to highlight the last scan entered is to top level a conditional formatting with the formula like

=A1=index($A:$A,match("zzz",$A:$A,1))

enter image description here

#3

To help you adding new tabs in your formula, you can refresh it by a little script, example for PKG-ID, BOL:

function myFunction() {
  var id = '1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI'
  var ss = SpreadsheetApp.openById(id)
  var rng = []
  ss.getSheets().forEach(sh => rng.push(`IMPORTRANGE("${id}", "${sh.getName()}!A:J")`))
  var formula = `=QUERY({${rng.join(';')}}, "WHERE Col2 = '"&TEXTJOIN("' OR Col2 = '", TRUE, A:A)&"' OR Col3 like '"&TEXTJOIN("' OR Col3 like '", TRUE, A:A)&"'", 0)`
  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('PKG-ID, BOL').getRange('B3').setFormula(formula)
}

edit

by script

function artikleFinder() {
  var id = '1EO2dTznbgaWu1CCWl3OyAw54Zd3jtkhDuOgnal671KI'
  var source = SpreadsheetApp.openById(id)
  var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('TEST (script)')
  sh.getRange(3,2,sh.getLastRow(),sh.getLastColumn()).clearContent()
  var list = sh.getRange('A3:A').getValues().filter(r => r[0] != '').join().split(',')
  var data = []
  list.forEach(function (crit) {
    source.getSheets().forEach(function (sh) {
      var blankRow = Array.from({ length: 1 }, () => Array.from({ length: 10 }, () => ''))
      var prov = sh.getRange(1,1,sh.getLastRow(),10).getValues().filter(
        r => (r[1] == crit || r[2] == crit || r[4] == crit || r[5] == crit || r[6] == crit)
      )
      if (prov.length){
        data.push(prov)
        data.push(blankRow)
      }
    })
  })
  result = data.flat()
  sh.getRange(3,2,result.length,result[0].length).setValues(result)
}

The result will be in the same order as the list in column A. However, if a row matches different criteria, that row will be duplicated

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文