Guest User

Untitled

a guest
Aug 19th, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onEdit(e) {
  2. var cfg = { // Please set this object.
  3. A5: {startRow: 6, endRow: 19},
  4. A19: {startRow: 20, endRow: 23},
  5. };
  6.  
  7. var activeRange = e.range.getA1Notation();
  8. var ranges = Object.keys(cfg);
  9. if (cfg[activeRange]) {
  10. var sheet = e.source.getActiveSheet();
  11. var values = sheet.getRange(ranges[0] + ":" + ranges[ranges.length - 1]).getValues();
  12. values.forEach(function(e, i) {
  13. if (e[0]) {
  14. sheet.showRows(cfg[ranges[i]].startRow, cfg[ranges[i]].endRow - cfg[ranges[i]].startRow);
  15. } else {
  16. sheet.hideRows(cfg[ranges[i]].startRow, cfg[ranges[i]].endRow - cfg[ranges[i]].startRow);
  17. }
  18. });
  19. }
  20. }
RAW Paste Data