Home > Software engineering >  Filter Data and Remove Rows Fast while keeping Header
Filter Data and Remove Rows Fast while keeping Header

Time:07-12

This is my final task. I am looking to filter data from column 17, that if anything in that column is less than 1, to remove the data in those rows. There is data that gets imported daily and their are a lot of rows that I want to filter fast and then delete those rows specified. I just want to keep the value of 1 in column 17. There is a frozen header at the top that does not move. What I have works but is extremely slow. Thank you for any help!

function filterData() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh1 = ss.getSheetByName('CancelRawData'); 

  var colCdata = sh1.getRange(1,17,sh1.getLastRow(),1).getValues()
   var filtered = colCdata.filter(String);
    Logger.log(filtered);

  for(let i = colCdata.length-1;i >= 0;i--){

     if(colCdata[i] <1 === true){

     sh1.deleteRow(i 1)
     }
  }
 SpreadsheetApp.getUi().alert("           
  • Related