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!
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);
};