title: How to copy specific rows from 3 google spreadsheet to another spreadsheet using google apps script
body: <p>I have a spreadsheet named Main-spreadsheet ,within them are 4 spreadsheets named sheet1,sheet2,sheet3 &amp; result. I want to copy conditional data from sheet1,sheet2,sheet3 to result sheet.Can anyone pls help me????</p>
  
  <p>This is my code:</p>
  
  <pre><code>  var ss = SpreadsheetApp.openById(DATA_SPREADSHEET_ID);
    var sheet = ss.getSheets()[3];
  
    var dataSs = SpreadsheetApp.openById(DATA_SPREADSHEET_ID);
    var dataSheet = dataSs.getSheets()[0];
  
    // Fetch all the data
    var data = getRowsData(dataSheet);
  
    // This is the data we want to display
    var columnNames = ["Name", "AC link", "Type"];
  
    // Index data by type
    var dataBytype = {};
    var types = [];
    for (var i = 0; i &lt; data.length; ++i) {
      var rowData = data[i];
      if (!dataBytype[rowData.type]) {
        dataBytype[rowData.type] = [];
        types.push(rowData.type);
      }
      dataBytype[rowData.type].push(rowData);
    }
  
    types.sort();
    var headerBackgroundColor = dataSheet.getRange(1, 1).getBackgroundColor();
    for (var i = 0; i &lt; types.length; ++i) {
      var sheet = ss.getSheetByName(types[i]) || 
          ss.insertSheet(types[i], ss.getSheets().length);
      sheet.clear();
      var headersRange = sheet.getRange(1, 1, 1, columnNames.length);
      headersRange.setValues([columnNames]);
      headersRange.setBackgroundColor(headerBackgroundColor);
      setRowsData(sheet, dataBytype[types[i]]);
    }
  </code></pre>
  
  <p>}</p>
  
  <p>it currently copy data fom sheet1 and makes a new sheet by type column</p>