Reputation: 89
I have a google sheets file that contains multiple tabs that are the names of various car manufacturers (ex: Toyota/Honda/Mercedes). For each of these car manufacturer tabs, the data columns within are the same. The data in each tab has 5 fields: Car Manufacturer, Vehicle Model, Customer Name, Sales Price, Date.
My goal is to try and create a macro google apps script that can turn some of the tabs in the Google Sheets file into independent Google Sheets files. I'm not familiar with Google Apps script and I'm having trouble figuring out how I can create a script that will allow me to call it through a macro where I vary the tab names to specify which tabs I would like to turn into independent Google Sheet files. I'm also not sure if there's a way to specify the name I would like the transformed file to have in the inputs/parameters of the macro.
Additionally, is there a way to list out the tabs that I want to split in a "Inputs" tab in the main Google Sheets file and have those called as the parameters of the macro script? I want to have 2 columns. The 1st column specifies the tab I want to move. The 2nd column specifies the name I want the tab that will be turned into an independent file to be named.
Upvotes: 0
Views: 899
Reputation: 36
var newSS = SpreadsheetApp.create("TAB_NAME");
var sourceTab = SpreadsheetApp.getActive().getSheetByName("TAB_NAME");
sheet.copyTo(newSS);
This is the main Engine for you. Please change "TAB_NAME" according to your requirement.
Upvotes: 1