I am hoping that someone might be able to help me out, I've been doing a lot of searching in the past few days and coming up short of a solution. Likely has to do with my lack of knowledge on coding... I know enough to be dangerous, just not enough to be effective or efficient!
To start, here is my goal.
- To create a document, that will contain a 'master list' of tasks for my marketing team.
- Each team member (currently 4) will have their own tab, which would only display tasks assigned to their name & have blank spaces under both 'completed' and 'canceled' columns...
- In addition to the team member tabs, there would be two others, 'Completed' and 'Canceled'. These tabs would contain any tasks, by any team member, that have a date under the respective column.
Currently, I managed to create a script that will delete all tabs (other than the master list) and recreate them with the assigned name. What I haven't been able to do is get each sheet to filter results. I can't seem to get any code that I've found in the forums to work. Nothing will filter the results automatically on any tab, it only copies the master list and renames the tabs. Can someone point me in the right direction?
Am I going about this in the most efficient way possible? Do I need a button that will run the script on command? Is there a way for the 'team member' sheets to update live based on what is entered into the master list? I tried to utilize this information (Filter data by column K in Google Script Editor (Google Sheets)) but was not able to make it function within my document.
Sorry for the lengthy, post, thanks in advance for any and all help!
A copy of the original file: https://docs.google.com/spreadsheets/d/141JochDYmt9RHRnyaY2iIoyAISCNNXFVUvEtJlBwtiQ/edit?usp=sharing
Example of the code:
function RunFilters() {
var name = "Adam";
/*ADAM*/
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Marketing').copyTo(ss);
/* Before cloning the sheet, delete any previous copy */
var old_name = ss.getSheetByName(name);
if (old_name) ss.deleteSheet(old_name); // or old.setName(new Name);
SpreadsheetApp.flush();
sheet.setName(name);
/* Make the new sheet active */
ss.setActiveSheet(sheet);
function myFunction() {
var ss = SpreadsheetApp.getSheetByName('Marketing'); //replace with source Sheet tab name
var range = ss.getRange('A:I'); //assign the range you want to copy
var data = range.getValues();
var tss = SpreadsheetApp.getActiveSpreadsheet(); //replace with destination ID
var ts = tss.getSheetByName('Adam'); //replace with destination Sheet tab name
ts.getRange(ts.getLastRow() + 1, 1, data.length, data[0].length).setValues(data);
var range = ts.getRange(ts.getLastRow() + 1, 1, data.length, data[0].length)
var rawData = range.getValues() // get value from spreadsheet 2
var data = [] // Filtered Data will be stored in this array
for (var i = 0; i < rawData.length; i++) {
if(rawData[i][5] == "Adam") // Check to see if column K says ipad if not skip it
{
data.push(rawData[i])
}
}
}
}