I am trying to add a sum formula of a column at the very bottom of that column using Google Apps scipt. The number of rows will vary, but the starting cell will remain constant.
I want to use a formula instead of inserting a static sum so that users can see the up to date sum without running any scripts.
constantslr+savingslr+needslr+wantslr = the number of rows to be summed. They are defined earlier.
I tried this with no luck
var sss = SpreadsheetApp.getActiveSpreadsheet(); var ss = sss.getSheetByName('Set Up Data'); ss.getRange(6+constantslr+savingslr+needslr+wantslr,4,1,1).setFormulaR1C1('=SUM(-['constantslr+savingslr+needslr+wantslr']C[0]:R[-1]C[0])');