title: Google Sheets Scripts relating to multiple columns
body: <p>With the help of a guidance video I was linked to on here, I've been able to write the following script which allows me to operate a dependent dropdown on my spreadsheet</p>
  
  <pre><code>function onEdit(){
  
    var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Operators");
  
    var activeCell = ss.getActiveCell();
  
    if(activeCell.getColumn() == 10 &amp;&amp; activeCell.getRow() &gt; 8){
  
      activeCell.offset(0, 1).clearContent().clearDataValidations();
  
      var headers = datass.getRange(1, 1, 1, 2).getValues();
  
      var headersIndex = headers[0].indexOf(activeCell.getValue()) + 1;
  
      if(headersIndex != 0){
  
          var validationRange = datass.getRange(2, headersIndex, datass.getLastRow());
          var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
          activeCell.offset(0, 1).setDataValidation(validationRule);
  
      }
  
    }
  
  
  
  }
  </code></pre>
  
  <p>It works!!! which is fantastic. However, I have a question which would relate to the following line of the above script</p>
  
  <pre><code>if(activeCell.getColumn() == 10 &amp;&amp; activeCell.getRow() &gt; 8){
  </code></pre>
  
  <p>Column 10 on my spreadsheet relates to column J, which is where the dependent dropdown in column K pulls its information from to supply the correct info in the dependent dropdown, and with this line included, my script works fine. However, I also have repeats of this in columns N (column number 14), R (column number 18) &amp; V (column number 22) which all supply the same information as for column J for the dependent dropdown in the following column.</p>
  
  <p>So basically my question is can I incorporate column numbers 14, 18 and 22 into this script to work in the same way as column 10 whilst keeping them independent of one another? - ie in that I don't want to pick something relating to column J and it duplicates into column N.</p>
  
  <p>I have tried to simply create the following line:</p>
  
  <pre><code>if(activeCell.getColumn() == 10, 14, 18, 22 &amp;&amp; activeCell.getRow() &gt; 8){
  </code></pre>
  
  <p>and this works in the sense that it allows me to work all of my dependent dropdowns independently of one another as I require. However, this is wreaking havoc with other data validation within my spreadsheet - in fact the next 2 cells after each of my dependent dropdowns are checkboxes and when using this amended line, my selecting something from a dependent dropdown is actually then causing the deletion of the checkbox in the next cell - which I obviously don't want to happen!</p>
  
  <p>Now, I have fully solved the problem by creating multiple functions on my script for each of my columns by creating the following at the top of my script</p>
  
  <pre><code>function onEdit(){
    j();
    n();
    r();
    v();
  
  }
  </code></pre>
  
  <p>and then setting separate functions for each of these and this works absolutely perfectly. So I have a solution and yet here I am asking for help and that is simply because I would prefer to have everything within one short script than have to have 4 or 5 scripts for each of my columns. Is this possible or do I already have the best solution to this particular problem?</p>