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

197
Visualizações
How can I make a macro dynamic in google sheets?

I've been trying to create a dynamic macro that copies the previous row and pastes it in the actual one. I've been able to create it, and it runs each time that I change the sheet (on change trigger). Until then, everything is fine.

The thing is that I'm only able to do it for a specific row, i.e., I've created it for row 11, however, once that it has run in row 11, I want it to work for row 12, once that row 12 is fulfilled, then it goes to row 13, and so on.

This is what I have now:

function copyandnumber() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('L11').offset(-1, 0, 1, 25).copyTo(spreadsheet.getRange('L11'), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};

Do you know how to change this 11 by something dynamic, for it to work on every row?

Thank you very much!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try

function copyandnumber() {
  var spreadsheet = SpreadsheetApp.getActive();
  var lastRow = spreadsheet.getLastRow();
  spreadsheet.getRange('L'+lastRow).offset(-1, 0, 1, 25).copyTo(spreadsheet.getRange('L'+lastRow), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};
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