vendredi 19 février 2021

Slow loop to find and copy

Good day everybody!

I'm developing a solution in GScript and I can't find the right way to do what I want.

I want the following things to happen:

  1. IF there's a specific letter in a specific range;
  2. Grab the entire row;
  3. Copy it to another sheet.

Sometimes, there's HUNDREDS of row to grab and copy. Here's my code for the moment:

for(var i = 0; i<rapport.length-1; i++) {
    if(colonneCode[i] == code.getResponseText()) {
      ligneCode[v] = i;
      v++;
    }
  }

for(var i = 0; i<ligneCode.length;i++) {
    
    var codeLastRow = 12;
    var copySource = sheet.getRange(ligneCode[i]+10, 1, 1, 16);
    var copyTarget = feuille.getRange(feuille.getLastRow()+1,1,1,16);
    copyTarget.setValues(copySource.getValues());
    copySource.copyTo(copyTarget, {formatOnly:true});

  }

Thanks!

Aucun commentaire:

Enregistrer un commentaire