title: Google Sheets Macro not completing
body: <p>I'm trying to parse a CSV file using Google Sheets macros. I've recorded all the steps as individual macros, and one by one they work fine, but when I combine into one macro, it doesn't run properly. The point at which it stops working is after the <code>PODdateformatting</code> part has completed and it's run through the first three lines of <code>Daystodeliverformula</code>. Cell H2 is populated with the formula, but the formula doesn't then autofill down the rest of the column. Any ideas? Or indeed, am I going about this all wrong and need a good talking to? :-)</p>
  
  <pre class="lang-js prettyprint-override"><code>function TheWholeShebang() {
    var spreadsheet = SpreadsheetApp.getActive(); // start of DeletedUnwantedColumns
    spreadsheet.getRange('AA:DE').activate();
    spreadsheet.getActiveSheet().deleteColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
    spreadsheet.getRange('W:X').activate();
    spreadsheet.getActiveSheet().deleteColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
    spreadsheet.getRange('R:U').activate();
    spreadsheet.getActiveSheet().deleteColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
    spreadsheet.getRange('H:P').activate();
    spreadsheet.setCurrentCell(spreadsheet.getRange('P1'));
    spreadsheet.getActiveSheet().deleteColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
    spreadsheet.getRange('A:E').activate();
    spreadsheet.setCurrentCell(spreadsheet.getRange('E1'));
    spreadsheet.getActiveSheet().deleteColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns()); // end of DeletedUnwantedColumns
  
    var spreadsheet = SpreadsheetApp.getActive(); // start of Addcolumnsandheaderlabels
    spreadsheet.getRange('A:F').activate(); 
    spreadsheet.getActiveSheet().insertColumnsAfter(spreadsheet.getActiveRange().getLastColumn(), 6);
    spreadsheet.getActiveRange().offset(0, spreadsheet.getActiveRange().getNumColumns(), spreadsheet.getActiveRange().getNumRows(), 6).activate();
    spreadsheet.getRange('G1').activate();
    spreadsheet.getCurrentCell().setValue('POD Date (formatted)');
    spreadsheet.getRange('H1').activate();
    spreadsheet.getCurrentCell().setValue('Days to Deliver');
    spreadsheet.getRange('G2').activate(); // end of Addcolumnsandheaderlabels
  
    var spreadsheet = SpreadsheetApp.getActive(); // start of PODdateformatting
    spreadsheet.getRange('G2').activate()
    .setFormula('=DATE(LEFT(D2,4),mid(D2,5,2),right(D2,2))');
    spreadsheet.getActiveRange().autoFillToNeighbor(SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES); // end of PODdateformatting
  
    var spreadsheet = SpreadsheetApp.getActive(); //start of Daystodeliverformula
    spreadsheet.getRange('H2').activate()
    .setFormula('=NETWORKDAYS(E2,G2,Instructions!$B$15:$B$40)-1');
    spreadsheet.getActiveRange().autoFillToNeighbor(SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES); // end of Daystodeliverformula
  };
  </code></pre>