Home > Enterprise >  How to skip Row in the following App Script in Google Sheet?
How to skip Row in the following App Script in Google Sheet?

Time:04-09

I am Copy and Pasting the data one sheet another sheet with cell value following script working fine.

I need to Skip the row 1 & 2 will copying in Maint.Schedule sheet

function moveRows() {
  var ss=SpreadsheetApp.getActive();
  var sheet=ss.getSheetByName('Maint. Schedule');
  var vA=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
  var csh=ss.getSheetByName('History');
  var d=0;//deleted row counter
  var data=[];
  for(var i=0;i<vA.length;i  ) {
    if (vA[i][12]=='Completed') {
      data.push(vA[i]);
      sheet.deleteRow(i 1-d  );//increment deleted row counter as you delete rows
    }
  }
  csh.getRange(csh.getLastRow() 1,1,data.length,data[0].length).setValues(data);
}

Thanks in Advance

Johnn

CodePudding user response:

Change for(var i=0;i<vA.length;i ) by

for(var i=2;i<vA.length;i  )
  • Related