title: Faster way to copy rows of data to different sheets by column value
body: <p>I'm trying to find a faster way to copy specific rows of a sheet to different sheets. Iterating through them as done in code below takes too much time it leads to timeout.</p>
  <p>Some information about origin sheet:</p>
  <ol>
  <li>Has already a blocked header</li>
  <li>Has around 5000 rows</li>
  <li>Column A has a header &quot;Project&quot;</li>
  <li>Sheet is sorted by Column A</li>
  </ol>
  <p>Goal is to copy range of all rows for each project from origin sheet to a blank sheet that is named from specific project - so all rows that has in column e.g. &quot;ProjectA&quot; in column A are in a sheet called &quot;ProjectA&quot;.</p>
  <p>Here is a code that is working, but it is using very slow iteration, so I'm waiting around 20 minutes or even get a timeout when I'm processing it:</p>
  <pre><code> var sheet = SpreadsheetApp.getActiveSheet();
      var columnRoom = sheet.getRange(&quot;A:A&quot;).getValues();
      var rows = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
      var header = rows[0];
      var completedRooms = []
      var last = columnRoom[1][0]
      for (var i = 1; i &lt; columnRoom.length; i++) {
          if (!completedRooms.includes(columnRoom[i][0])) {
              if (columnRoom[i][0] === &quot;&quot;) {
                  var currentSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet(&quot;No Room&quot;);
              } else {
                  var currentSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet(columnRoom[i][0]);
              }
              currentSheet.appendRow(header);
              currentSheet.appendRow(rows[i]);
              completedRooms.push(columnRoom[i][0])
              last = columnRoom[i][0]
          } else if (last == columnRoom[i][0]) {
              var currentSheet = SpreadsheetApp.getActiveSpreadsheet()
              currentSheet.appendRow(rows[i]);
          }
      }
  </code></pre>
  <p>Is there a way to do it faster? I'm thinking about appending specific rows to a range and use copyTo but I can't arrange it, maybe use map function?</p>