Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
paste on top of the row instead of the bottom row

at the moment I have a sheet that has a script that is time triggered, the script at the end of the day will copy sheets at the bottom of the target sheet, everytime I am trying to do targetSheet.getrange(1,1) + 1; it's not converting range to int. can someone please help?

   function copyData() {
  
  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = spreadSheet.getSheetByName('copiedPausingSheet');

  let sourceRange = sourceSheet.getDataRange();
  let sourceValues = sourceRange.getValues();


  let rowCount = sourceValues.length;
  let columnCount = sourceValues[0].length;

  let targetSheet = spreadSheet.getSheetByName('collectivePausingData');
  let lastrowCount = targetSheet.getLastRow() + 1;
  
  let targetRange = targetSheet.getRange(lastrowCount,1, rowCount,columnCount);

  targetRange.setValues(sourceValues);
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Is that what you mean? Paste values on the top of the sheet.

function copyData() {
  
  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = spreadSheet.getSheetByName('copiedPausingSheet');

  let sourceRange = sourceSheet.getDataRange();
  let sourceValues = sourceRange.getValues();


  let rowCount = sourceValues.length;
  let columnCount = sourceValues[0].length;

  let targetSheet = spreadSheet.getSheetByName('collectivePausingData');
  targetSheet.insertRows(1,sourceValues.length);
  
  let targetRange = targetSheet.getRange(1,1,sourceValues.length,sourceValues[0].length);

  targetRange.setValues(sourceValues);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Do you mean this?

function copyDataOnTop() {

  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = spreadSheet.getSheetByName('copiedPausingSheet');

  let sourceRange = sourceSheet.getDataRange();
  let sourceValues = sourceRange.getValues();

  let targetSheet = spreadSheet.getSheetByName('collectivePausingData');
  var targetValues = targetSheet.getDataRange().getValues();

  var allValues = [...sourceValues, ...targetValues];
  
  let targetRange = targetSheet.getRange(1,1,allValues.length,allValues[0].length);
  targetRange.setValues(allValues);
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda