title: How do I run a script across multiple tabs on google sheets?
body: <pre><code>var SHEET_NAME = 'In';
  var DATETIME_HEADER = 'datetime';
  
  function getColByHeader(headerval){
    var headers = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME).getDataRange().getValues().shift();
    var colindex = headers.indexOf(headerval);
    return colindex+1;
  }
  
  function onEdit(e) {  
    var ss = SpreadsheetApp.getActiveSheet();
    var cell = ss.getActiveCell();
    var datecell = ss.getRange(cell.getRowIndex(), getColByHeader(DATETIME_HEADER));
    // Conditions: 
    //  - edited (active) cell is in the first column
    //  - edited cell is not blank
    //  - corresponding datetime cell is blank 
    //  - active sheet is named [SHEET_NAME]
    if (cell.getColumn() == 1 &amp;&amp; !cell.isBlank() &amp;&amp; datecell.isBlank() &amp;&amp; ss.getName() == SHEET_NAME) {      
      datecell.setValue(new Date()).setNumberFormat(&quot;yyyy-MM-dd hh:mm&quot;);
    }
  };
  </code></pre>
  <p>Hi, I'm trying to make the above script to work on two different tabs on the same workbook - &quot;In&quot; and &quot;Out&quot;. I've tried a couple of different solutions but with no luck. Can anybody help me please.</p>