r/GoogleAppsScript • u/vcs935 • Dec 13 '19
I need help with my script for spreadsheets
hello, i am really new to this and i need help.
I have done this so far and it worked! however i want the name of the new spreadsheet to correspond with what i have on column c and line 2, then the second copy 3 and so on, what can i do?
function myFunction()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("otro"));
var sheet1 = SpreadsheetApp.getActiveSheet();
var dataRange = sheet1.getRange("A1:C5");
var data = dataRange.getValues();
for(i = 0; i < 6; ++i)
{
var rowData = data[i];
ss.duplicateActiveSheet()
}
}
function onOpen()
{
var ss2 = SpreadsheetApp.getActive();
var menuA = [{name: 'create Sheets', functionName:'myFunction'}];
ss2.addMenu('mis herramientas', menuA)
}
1
u/gh5000 Dec 14 '19
Try below var row data line
var sheetName = rowData[2] //column C
var newSheet = ss.duplicateActiveSheet()
newSheet.setName(sheetName)