Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onEdit()
- {
- //use the currently open sheet
- var sheet = SpreadsheetApp.getActiveSheet();
- //set the cells for increase/decrease/total
- var total1 = sheet.getRange("C2");
- var increase1 = sheet.getRange("C4");
- var decrease1 = sheet.getRange("C6");
- //get the current value of "total"
- var total1num = total1.getValue();
- //if "increase" was changed, calculate new "total" and set cells
- if (increase1.getValue() !== "")
- {
- total1num = total1num + increase1.getValue();
- total1.setValue(total1num);
- increase1.setValue("");
- }
- //if "decrease" was changed, calculate new "total" and set cells
- if (decrease1.getValue() !== "")
- {
- total1num = total1num - decrease1.getValue();
- total1.setValue(total1num);
- decrease1.setValue("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement