jimbogarner
Board Regular
- Joined
- Apr 22, 2010
- Messages
- 103
Hi,
I have got a spreadsheet, unfortunately my work restrictions mean I can't share it so I've snipped the necessary details below. As part of this I have a button which is pressed to create a new template and rename the tab based on the text input in the front sheet, I have a formula in to get the tab name based on another script added in, however, the cell only ever changes to 'copy of blank template' rather than updating to the new sheet name once the initial script has finished running. I've added a trigger to run upon change but it still doesn't like it.
..
The scripts I've got are as follows;
To duplicate sheet:
function createNewSheet () {
var wb = SpreadsheetApp.getActiveSpreadsheet();
var thissheet = SpreadsheetApp.getActiveSheet();
var cpyShName = "Blank Template"
//var cpyShName = sheet.getRange(2,3).getValues();
var newShName = thissheet.getRange(1,2).getValues();
var sheet = SpreadsheetApp.getActive().getSheetByName(cpyShName);
sheet.activate();
//var sheet = wb.getSheetByName(copyShName);
//sheet.getRange(13,3).setValue (newShName)
sheet.copyTo(wb).setName(newShName);
var sheet = SpreadsheetApp.getActive().getSheetByName(newShName);
sheet.activate();
}
To get tab name:
function GetTab() {
var tabName = SpreadsheetApp.getActiveSheet().getName();
return(tabName);
}
I then have a trigger which runs;
Any help that would be ideal!
Thanks,
James
I have got a spreadsheet, unfortunately my work restrictions mean I can't share it so I've snipped the necessary details below. As part of this I have a button which is pressed to create a new template and rename the tab based on the text input in the front sheet, I have a formula in to get the tab name based on another script added in, however, the cell only ever changes to 'copy of blank template' rather than updating to the new sheet name once the initial script has finished running. I've added a trigger to run upon change but it still doesn't like it.
The scripts I've got are as follows;
To duplicate sheet:
function createNewSheet () {
var wb = SpreadsheetApp.getActiveSpreadsheet();
var thissheet = SpreadsheetApp.getActiveSheet();
var cpyShName = "Blank Template"
//var cpyShName = sheet.getRange(2,3).getValues();
var newShName = thissheet.getRange(1,2).getValues();
var sheet = SpreadsheetApp.getActive().getSheetByName(cpyShName);
sheet.activate();
//var sheet = wb.getSheetByName(copyShName);
//sheet.getRange(13,3).setValue (newShName)
sheet.copyTo(wb).setName(newShName);
var sheet = SpreadsheetApp.getActive().getSheetByName(newShName);
sheet.activate();
}
To get tab name:
function GetTab() {
var tabName = SpreadsheetApp.getActiveSheet().getName();
return(tabName);
}
I then have a trigger which runs;
Any help that would be ideal!
Thanks,
James