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

88
Visualizações
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 Respostas
Responde à pergunta

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 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