title: Servererror in Google App Script code
body: <p>In my Google Sheet I want to copy a range from all different sheets in the document to the first page as a summary. For this I tried to do it with this code:</p>
  
  <pre><code>function listAllTasks()
  {
    var startRow = 2;
    var startColum = 3;
  
    var rowIndex = 2;
  
    var document = SpreadsheetApp.getActive();
    var sheets = document.getSheets();
  
    // Skip first Sheet
    for(var i=1; i &lt; sheets.length ; i++)
    {
      var sourceRange = sheets[i].getDataRange();
  
      var rows = sourceRange.getNumRows() - 1;
      var columns = sourceRange.getNumColumns();
  
      sourceRange = sheets[i].getRange(startRow, startColum, rows, columns);
  
      sourceRange.copyFormatToRange(sheets[0], 1, columns, rowIndex, rows);
      sourceRange.copyValuesToRange(sheets[0], 1, columns, rowIndex, rows);
  
      rowIndex += rows;
    }
  }
  </code></pre>
  
  <p>The first pass from the loop works great but on the second pass it comes to a server error on line:</p>
  
  <pre><code>sourceRange.copyFormatToRange(sheets[0], 1, columns, rowIndex, rows);
  </code></pre>
  
  <p>The error does not give any information. It only says:</p>
  
  <blockquote>
    <p>Servererror. Please try again later...</p>
  </blockquote>
  
  <p>Do you have any ideas why? I know that my range is correct and if I try this with only one sheet in the document it works great. I have duplicated the sheet and then renamed it. Can that be a problem?</p>