Advertisement
bigfoot49211

Untitled

Jul 20th, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. function onEdit()
  2. {
  3. //use the currently open sheet
  4. var sheet = SpreadsheetApp.getActiveSheet();
  5.  
  6. //set the cells for increase/decrease/total
  7. var total1 = sheet.getRange("C2");
  8. var increase1 = sheet.getRange("C4");
  9. var decrease1 = sheet.getRange("C6");
  10. //get the current value of "total"
  11. var total1num = total1.getValue();
  12. //if "increase" was changed, calculate new "total" and set cells
  13. if (increase1.getValue() !== "")
  14. {
  15. total1num = total1num + increase1.getValue();
  16. total1.setValue(total1num);
  17. increase1.setValue("");
  18. }
  19. //if "decrease" was changed, calculate new "total" and set cells
  20. if (decrease1.getValue() !== "")
  21. {
  22. total1num = total1num - decrease1.getValue();
  23. total1.setValue(total1num);
  24. decrease1.setValue("");
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement