【问题标题】:Removing a row containing a specific text in Google Sheets在 Google 表格中删除包含特定文本的行
【发布时间】:2019-10-30 12:13:44
【问题描述】:

我有一个大约 3000 列的数据集,但其中一些列有几个包含单元格“na”的单元格。这些行并不重要,因为它们没有我需要的数据,谷歌表格中是否有一个命令可以突出显示包含该文本的整行或删除包含该文本的整行?

任何帮助将不胜感激。

https://docs.google.com/spreadsheets/d/1u8OUfQOzgAulf1a8bzQ8SB5sb5Uvb1I4amF5sdGEBlc/edit?usp=sharing

我的文档^.

【问题讨论】:

  • 您可以使用过滤数据并在新工作表中复制粘贴。希望你明白我的意思。
  • 你有多少行数据? 3,000 列相当多,仅用于单行。 match 函数可以工作,但重新计算时间可能是个问题。如果您仍然要删除该行,我会选择一个检测“na”然后删除该行的脚本

标签: regex google-apps-script google-sheets google-sheets-formula gs-conditional-formatting


【解决方案1】:

您可以使用此公式为所有 na 行着色:

=ARRAYFORMULA(REGEXMATCH(TRANSPOSE(QUERY(TRANSPOSE($A1:$Z),,999^99)), " na "))

【讨论】:

  • 再次感谢@player0,再次感谢您的帮助!只要它们突出显示,我就可以按颜色过滤它们并删除它们。非常感谢!
  • 您好,我运行了命令,它一直在突出显示行,但它只完成了 7000 行中的 200 行。我已经离开谷歌表已经大约 5 个小时了。有什么办法可以加快速度?
  • 你能分享一份你的工作表吗?
  • 你可以这样试试吗? docs.google.com/spreadsheets/d/…
  • 这正是我一直在寻找的,我不知道为什么我的电脑一直花很长时间才能突出显示某些行。你是救生员。
【解决方案2】:

此答案基于我的理解,如果我错了,请见谅。您可以使用条件格式突出显示所有 NA 文本

这是我使用的规则

这里有另一个可能对你有帮助的答案

  1. Delete a row in Google Spreadsheets if value of cell in said row is 0 or blank

  2. Google Sheets: delete rows containing specified data

  3. Deleting Cells in Google Sheets without removing a whole row

抱歉英语不好。

【讨论】:

    【解决方案3】:

    我不确定我的理解是否很好,但请看下面你能做什么。 这是一个谷歌脚本函数,它为“na”所在的整个列着色

      function myFunction() {
    //get the spreadsheet where the function is running
      var ss = SpreadsheetApp.getActive()
      //Replace "the name of your sheet" by your sheet name" be careful its case sensitive.
      var sheet = ss.getSheetByName("The name of your sheet")
      //Get all your data as an array (If your sheet has no header, change 2 by 1 and (sheet.getLastRow()-1) by sheet.getLastRow())
      var values = sheet.getRange(2,1,(sheet.getLastRow()-1), sheet.getLastColumn()).getValues();
    
      //For each column
      for (var i = 0; i< sheet.getLastColumn(); i++){
      //using function map is helping to select one column by one column
        var mapValues = values.map(function(r){return r[i]});
        //Searching your keyword in the column, in your case it's "na"
        var position = mapValues.indexOf("Put the string that you are looking for, in your case 'na'");
        //if at least there is one "na" inside the column
        if( position >-1){
        //then this color have to get red color as a background
           var wholeColumn = sheet.getRange(2,(i+1),(sheet.getLastRow()-1));
           wholeColumn.setBackground("red");
        }
      }
    }``
    

    让我知道它是否有效

    【讨论】:

      猜你喜欢
      • 2018-03-15
      • 2017-11-22
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多