Update data from a Spreadsheet - App Script

0

I am doing a data transfer of several spreadsheets to a single one, what I do is transfer the last data of certain columns to the master spreadsheet and also insert them in the last available row of certain columns, for now, I insert all the data but I would like to know how I can make it examine the master spreadsheet so that if those data already exist do not delete them but update it. The script that I have is the following ...

      function  Gas10(){  
      var ss1 = SpreadsheetApp.openById("ID"); 
      var ssh1 = ss1.getSheetByName("Hoja 1");


    var lastRow1 = ssh1.getLastRow();
    var gtRange1 = ssh1.getRange("C"+(lastRow1)+":K"+(lastRow1)).getValues();
    var gtRange2= ssh1.getRange("A" + (lastRow1)).getValue();

    var ss2 = SpreadsheetApp.getActiveSpreadsheet();

    var ssh2 = ss.getSheetByName("Hoja 2");
    var lastRow2 = ssh2.getLastRow() + 1;
    var setRange1 = ssh2.getRange(lastRow2, 4, gtRange1.length, gtRange1[0].length).setValues(gtRange1);
    var setRange2 = ssh2.getRange(lastRow2, 3).setValue(gtRange2);            

}

As I repeat, I need to know how I can do it when I insert a piece of information (I already do that), but update it if it already exists. This question was posted again but on the server in English. StackOverflow .

Edit

This is a sample that you make so that the question could be better understood, in which I have 2 sheets and from sheet 1 I copy the last data of a certain range and I paste them in sheet 2 in the last available row and what I try to do is that if the Name, Num and Project are already in the Sheet 2, update the ID. In the example you will understand it better.

    
asked by Leon K. 03.09.2018 в 19:28
source

0 answers