Im trying to make a spreadsheet to manage my money/expenses and have run into a problem trying to automate my process
I want to make a piece of code that runs every time a cell has been edited in the sheet.
When triggered, i want it to calculate ssum, lsum and betal(in the loop), and then put it into 3 different cells. The code behaves as expected, but the onedit trigger doesnt work.
This is my code:
function regnudbetalprocent() {
var betal = 0;
var i = 1;
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
var sum = activeSheet.getRange(18, 5).getValue();
var ssum;
var lsum;
var ssumori = activeSheet.getRange(3, 8).getValue();
var lsumori = activeSheet.getRange(4, 8).getValue();
var fuld = activeSheet.getRange(18, 2).getValue();
while(betal < sum){
ssum = ((ssumori - fuld / 2) / 100) * i;
lsum = ((lsumori - fuld / 2) / 100) * i;
betal = ssum + lsum;
i++;
}
if (betal > sum) {
var output = [
[ssum,lsum],
["Samlet",betal]
]
return output;
}
}
The output variable sets the neighbouring cells accordingly from where the function is called
I've tried with setValue and clearContent, but it i cant edit outside the cell from where the function is called. I've used Edit -> current project's triggers to add an onEdit trigger, which increments each time i edit the sheet, but nothing happens.. I'm burned out
Can someone guide me? how do i get what i want?
I've tried with setValue and clearContent, but it i cant edit outside the cell from where the function is called.
. Can I ask you where you want to put the result value, when a cell is edited? – Tanaike