title: Upgrading a script
body: <p>So i have this script</p>
  <pre><code> function onEdit(e) {
  
    var editRange = e.range;
    var rb1 = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(&quot;RadioButton1&quot;);
  
    // return if out of range
    if (editRange.getSheet().getSheetName() != rb1.getSheet().getSheetName()) return;
  
    var radioRange = { // RadioButton1 range
      top : rb1.getRow(),
      bottom : rb1.getLastRow(),
      left : rb1.getColumn(),
      right : rb1.getLastColumn()
    };
  
    var thisRow = editRange.getRow();
    if (thisRow &lt; radioRange.top || thisRow &gt; radioRange.bottom) return;
  
    var thisCol = editRange.getColumn();
    if (thisCol &lt; radioRange.left || thisCol &gt; radioRange.right) return;
  
    // make RadioButton1 named range behave like radio button
    var numRows = rb1.getNumRows();
    var numCols = rb1.getNumColumns();
    var writeValues = []
    for (var i = 1; i &lt;= numRows; i++) {
      var row = []
      for (var j = 1; j &lt;= numCols; j++) {
        var currentRange = rb1.getCell(i,j);
        var radioValue;
        if ( currentRange.getA1Notation() == editRange.getA1Notation() ) {
          radioValue = true;  
        } else {
          radioValue = false; 
        }
        row.push(radioValue)
      }
      writeValues.push(row)
    }
    rb1.setValues(writeValues)
  }
  </code></pre>
  <p>from <a href="https://stackoverflow.com/questions/59226666/switch-based-on-checkbox-tied-between-two-cells-in-google-sheets">Switch based on checkbox tied between two cells in Google Sheets</a></p>
  <p>so sorry i for got i have put the checkboxes into separate ranges</p>
  <p><a href="https://i.stack.imgur.com/1A3xd.png" rel="nofollow noreferrer">What ranges i Have</a></p>
  <p>how do i make this now work for multiple ranges please?</p>
  <p>also if there is a way to set the cells the check boxes are in rather than using a range to determine the checkbox pairs so i can move them around the sheet and tell the script where to look that would be better</p>
  <p><a href="https://docs.google.com/spreadsheets/d/1YWfloYTN1PLjohvIGS0UMGQrR2lnZQCNiIN0_Na1ijM/edit?usp=sharing" rel="nofollow noreferrer">My Google Doc</a></p>