script editor google sheets create new sheet 1

script editor google sheets create new sheet

function onOpen() {
    var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    var yourNewSheet = activeSpreadsheet.getSheetByName("Name of your new sheet");

    if (yourNewSheet != null) {

    yourNewSheet = activeSpreadsheet.insertSheet();
    yourNewSheet.setName("Name of your new sheet");

Here is what the above code is Doing:
1. It’s creating a function called onOpen()
2. It’s getting the active spreadsheet
3. It’s getting the sheet called “Name of your new sheet”
4. If the sheet exists, it’s deleting it
5. It’s creating a new sheet
6. It’s renaming the new sheet to “Name of your new sheet”

Similar Posts