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

89
Views
Copy non blank cells to exact column and row

I need to copy data from a selected range (Y5:Z198) to cell (Y206) but somehow I can only make it to appendRow and paste only on column A. Can someone help me, please?

function CopyData(CopyData) {
    var ss = SpreadsheetApp.getActive();
    var sh1 = ss.getSheetByName("CAPA");
    var sh2 = ss.getSheetByName("CAPA");
    var rg1 = sh1.getRange("Y5:Z198");
    var vA = rg1.getValues();

    for (var i = 0; i < vA.length; i++) {
        if (vA[i][1]) {
            sh2.appendRow(vA[i]);
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this code to copy the data

function CopyData(CopyData) {
  const dstRow = 206;
  let ss        = SpreadsheetApp.getActive(),
      sheet     = ss.getSheetByName('CAPA'),
      srcRange  = sheet.getRange('Y5:Z198'),
      srcValues = srcRange.getValues(),
      filtered  = srcValues.filter(item => item[1]);  // filter the data being copied
    
    // Define the range to insert
    // 'Y'+dstRow -> Y206
    // filtered.length -> the number of rows in the filtered array of data
    // ':Z'+(dstRow-1+filtered.length) -> bottom right cell

    sheet.getRange('Y'+dstRow+':Z'+(dstRow-1+filtered.length)).setValues(filtered);
}
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!