【问题标题】:Import data between spreadsheets where column = value?在列 = 值的电子表格之间导入数据?
【发布时间】:2013-04-11 15:18:38
【问题描述】:

注意:我的问题类似于 Googe Spreadsheets 的 ImportRange 函数。

是否可以在 Google 电子表格或 Microsoft Excel 中根据单元格值导入数据?

例如,我可以将 Sheet1 的内容复制到 B == "foo" 列的另一个工作表吗?

目标(表 1):

目标表应该只复制第 2 行和第 4 行,因为它们是唯一包含“foo”的行

编辑:

对于 Google Docs,我正在寻找这样的东西:

=ImportRange("spreadsheetkey", QUERY('sheetname'!A6:E10, "SELECT A, B = 'foo'")) 但是我无法让它工作。

【问题讨论】:

  • 使用工作表函数,不太可能(虽然我没有对 GoogleDocs 做过任何事情)使用 VBA 或 GoogleDocs 脚本是可能的。
  • For example, can I copy contents of Sheet1 to another sheet where column B == "foo"? 是的,你可以。看到这个链接stackoverflow.com/questions/11631363/…

标签: excel spreadsheet google-sheets google-docs google-drive-api


【解决方案1】:

你可以按照你说的那样做,但不是在 ImportRange 中使用 Query,而是在 Query 中使用 ImportRange,所以:

=QUERY((ImportRange("spreadsheetkey", "sheetname!A6:E10")), "Select columnnumbers like Col1,Col2 etc where _Criteria for select, 比如 (B contains 'foo ')如果你想按哪一列排序")

【讨论】:

    【解决方案2】:

    你可以这样做:

    首先,在额外的列(例如 D 列)中标识要复制的行/单元格:

    range("D" & range("A" & activesheet.rows.count).end(xlup).row).formula= "=IF(B:B=""foo"", NA(),"""")
    

    接下来,使用 SpecialCells 选择 A 列和 B 列中 D 列显示 NA#的单元格

    range("D1:D6").specialcells(xlcelltypeformulas, xlerrors).offset(0,-2).copy
    othersheet.range("A1").pastespecial xlpasteall
    

    这应该让你开始使用一些代码来玩

    当然,你也可以不使用VBA,只需将公式粘贴进去,使用F5,SpecialCells对话框...

    【讨论】:

      【解决方案3】:

      您需要像这样使用 importrange 包装查询:

      =QUERY(importrange("spreadsheet key","sheetname!A6:E10"), "SELECT A where B='foo'")
      

      【讨论】:

        【解决方案4】:

        您可以使用 FILTER 功能:

        =FILTER(IMPORTRANGE("spreadsheet_url", "'sheet_name'!A6:E10"),
        IMPORTRANGE("spreadsheet_url", "'sheet_name'!B6:B10")="foo")
        

        【讨论】:

          猜你喜欢
          • 2012-05-03
          • 2020-07-19
          • 1970-01-01
          • 2014-07-22
          • 2010-09-27
          • 2019-12-20
          • 1970-01-01
          • 2015-11-06
          • 1970-01-01
          相关资源
          最近更新 更多