Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!