Delete row in Google Sheets if certain “word” is found in cell

后端 未结 2 524
我在风中等你
我在风中等你 2021-01-07 09:44

I have a Google Sheet with over 3000 rows. Some of the rows contain words that are not relevant..So I need a way to delete these in bulk. For example, cells will contain som

2条回答
  •  花落未央
    2021-01-07 10:44

       function deleteRows() {
      var sheet = SpreadsheetApp.getActiveSheet();
      var rows = sheet.getDataRange();
      var numRows = rows.getNumRows();
      var values = rows.getValues();
    
      var toDelete = [];
    
    var re = new RegExp('old','gi'); 
      for (var row = 0; row < values.length; row++) { 
      for(var column = 0;column= 0;deleteRow--){
        sheet.deleteRow(toDelete[deleteRow]+1);
      }
    
      SpreadsheetApp.flush();
    };
    

提交回复
热议问题