I'm using this simple function to quickly autofill the respective column with a formula (in the 2nd row). However, I found that if I happen to want to modify smth in a cell (say C4) at one point, then add more rows and need to re-run it will do it from C2 again and will overwrite any modifications I've made with the formula again. This is why I'd like something more dynamic (set the formula in the last row, referencing other columns/cells from that respective row). The quick fixes I thought of don't take it as a correct range. I've tried to avoid using loops or other complex solutions and just referencing the last row, but it doesn't seem to work. Is there an easy fix I could make to this code. You can see spreadsheet example here here. I hope it makes sense.
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow();
var FillC = ss.getRange(2,3,lr-1);
ss.getRange("C2").copyTo(FillC);
//ss.getRange("C"&lr).setFormula('A'&lr&'B'&lr)
//ss.getRange("C2").setFormula (='A'& lastrow(in this case 5) & 'B'& lastrow(5)
}