I have made a formula (I am in no way a programmer) to work for my Google Sheets needs. But I have to run the code manually once more cells are updated from a google form. I then take certain cells to another sheet to present a report from this information, so I need this formula of mine to run every time there is new information. I also have a column ("O:O") that loads from a previous date, which I would not like it to load to the next day until there is a timestamp from a form entry because it makes the sheet load varios days in advance.
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("N2").setFormula("=(I2*0.01)+(H2*0.05)+(G2*0.1)+(F2*0.25)+(E2*0.5)+(D2)+(C2)");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(2, 14, lr-1);
ss.getRange("N2").copyTo(fillDownRange);
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("M2").setFormula("=N2-L2-J2");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(2, 13, lr-1);
ss.getRange("M2").copyTo(fillDownRange);
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("P3").setFormula("=N3-O3");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(2, 16, lr-1);
ss.getRange("P3").copyTo(fillDownRange);
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("O3").setFormula("=M2");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(3, 15, lr+1);
ss.getRange("O3").copyTo(fillDownRange);
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("Q2").setFormula("=A2");
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("Q2").setNumberFormat('dd MMM yyyy');
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(2, 17, lr-1);
ss.getRange("Q2").copyTo(fillDownRange);
}
My formula is working but like I said I would like the O column to not load ahead of entries and rather wait for a new timestamp to work and I would like my formula to calculate as soon as there is new information. Thanks in advance and sorry if my question is poorly made. (My first time on Stack Exchange)
I would like the O column to not load ahead of entries
What are entries? You also say ` I would like my formula to calculate as soon as there is new information` How is your sheet getting new information. I would probably be helpful to see your spreadsheet and give us examples of what you want to change. - Cooper