在Google表格中删除包含特定文本的行

问题描述 投票:1回答:3

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

任何帮助将不胜感激。

Example of columns that have <code>na</code> in cells, the row must be deleted

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

我的文档^。

regex google-apps-script google-sheets google-sheets-formula gs-conditional-formatting
3个回答
2
投票

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

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

0


1
投票

此答案基于我的理解,如果我错了,抱歉。您可以使用条件格式突出显示所有不适用的文本enter image description here

这是我使用的规则

enter image description here

以下是其他可能对您有帮助的答案

  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

对不起,英语不好。


1
投票

我不确定我的准备是否很好,但是请参阅下面的说明。这是一个Google脚本功能,可以为“ 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");
    }
  }
}``

让我知道是否可行

© www.soinside.com 2019 - 2024. All rights reserved.