Google App Script help

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.

1734518440036.png

1734518450559.png

1734518464691.png
..

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;

1734518672906.png


Any help that would be ideal!

Thanks,

James
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top