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

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

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