0
votes

I'm trying to make something that takes a text input from a cell, and when you click a button, it will make a new sheet, and name it the text you put in the cell. Here,:enter image description here

1

1 Answers

0
votes

You can try this:

First, get the value from the cell with the getValue() method:

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var newSheet = sheet.getRange("B4").getValue();

It returns a String, so you can use it with the create method:

SpreadsheetApp.create(newSheet);

Then, create the button from Insert > Drawing and assign the function to it.

EDIT

Since the question was about Sheets and not Spreadsheets, I'm adding the solution for it:

var sheet = SpreadsheetApp.getActiveSpreadsheet();
var newSheet = sheet.getRange("B4").getValue();

sheet.insertSheet(newSheet);

Reference: https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#insertSheet(String)