title: Combine two onEdit() functions in google app script
body: <p>I have a two simple scripts two make a dynamic dependent  drop-down lists based on two different data sources in google sheet. In my sheet value in column B depends on the A, and value in column I depends on H. If I run one script, second doesn't work. I know I have to combine them into one function but I am totally begginer in JavaScript so thats why I ask you. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onEdit(){
    var tabLists = "source1";
    var tabValidation = "main";
    var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabLists);
    
    var activeCell = ss.getActiveCell();
    
    if(activeCell.getColumn() == 1 &amp;&amp; activeCell.getRow() &gt; 1 &amp;&amp; ss.getSheetName() == tabValidation){
      
      activeCell.offset(0, 1).clearContent().clearDataValidations();
      
      var makes = datass.getRange(1, 1, 1, datass.getLastColumn()).getValues();
      
      var makeIndex = makes[0].indexOf(activeCell.getValue()) + 1;
      
      if(makeIndex != 0){
      
          var validationRange = datass.getRange(3, makeIndex, datass.getLastRow());
          var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
          activeCell.offset(0, 1).setDataValidation(validationRule);
    
       }  
        
    }
   
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onEdit(){
    var tabLists = "source2";
    var tabValidation = "MAINTENANCE";
    var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabLists);
    
    var activeCell = ss.getActiveCell();
    
    if(activeCell.getColumn() == 8 &amp;&amp; activeCell.getRow() &gt; 1 &amp;&amp; ss.getSheetName() == tabValidation){
      
      activeCell.offset(0, 1).clearContent().clearDataValidations();
      
      var makes = datass.getRange(1, 1, 1, datass.getLastColumn()).getValues();
      
      var makeIndex = makes[0].indexOf(activeCell.getValue()) + 1;
      
      if(makeIndex != 0){
      
          var validationRange = datass.getRange(3, makeIndex, datass.getLastRow());
          var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
          activeCell.offset(0, 1).setDataValidation(validationRule);
    
       }  
        
    }
    
  }
   </code></pre>
  </div>
  </div>
  </p>
  
  <p>I have tried to combine them into one If statement with more variables like  "tablist1", "tablists2", "datass1", "datass2" etc. Im so consufed so I would be grateful If you help me. </p>
  
  <p>Regards </p>