I have a spreadsheet named Main-spreadsheet ,within them are 4 spreadsheets named sheet1,sheet2,sheet3 & result. I want to copy conditional data from sheet1,sheet2,sheet3 to result sheet.Can anyone pls help me????
This is my 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 < 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 < 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]]);
}
}
it currently copy data fom sheet1 and makes a new sheet by type column