Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Clear cells based on checkbox repeated Google Sheets

$
0
0

I have checkboxes in columns A, E, H, L, O, S, V, and ZI have a script that is working which allows me to check the box in a2 and it deletes data in e2 and f2. I then am able to reverse the script so selecting the checkbox in e2 will delete data in a2 and b2. Perfect.

The problem is I need it to do it for 29 rows and I can't figure out how to make it work unless I duplicate the script 232 times.

So the checkboxes go together as follows;

  • A needs to delete E and F - while E needs to delete A and B
  • H needs to delete L and M - while L needs to delete H and I
  • O needs to delete S and T - while S needs to delete O and P
  • V needs to delete Z and AA - while Z needs to delete V and W

I hope this makes sense.

Is there an easy way to do this or am I stuck duplicating the script?

function onEdit9(e) { var ss = e.source; var activeSheet = ss.getActiveSheet(); var cell = e.range; if (activeSheet.getName() == "OPEN" && cell.getA1Notation() == "E2" && cell.isChecked()){   activeSheet.getRange("a2:b2").clearContent(); }}function onEdit10(e) { var ss = e.source; var activeSheet = ss.getActiveSheet(); var cell = e.range; if (activeSheet.getName() == "OPEN" && cell.getA1Notation() == "A2" && cell.isChecked()){   activeSheet.getRange("E2:F2").clearContent(); }}

Note: the onEdit9 and onEdit10 are due to other onEdit scripts that are running.


Viewing all articles
Browse latest Browse all 9786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>