Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename only second sheet in a spreadsheet?

How do I create a script to rename the second sheet in a workbook no matter what the current sheet name is?

I have a script that deletes all of the sheets except for the 1st and 2nd one.

Then I want to rename the second sheet with today's date. I have everything else except renaming.

like image 562
VAGolfDad Avatar asked Jan 07 '13 14:01

VAGolfDad


People also ask

How do you name a second page in Excel?

Double-click the sheet tab, and type the new name. Right-click the sheet tab, click Rename, and type the new name.

Can I change something on one sheet and have it change on other sheets in the same document?

1. Ctrl + Click each sheet tab at the bottom of your worksheet (selected sheets will turn white). 2. While selected, any formatting changes you make will happen in all of the selected sheets.

How can we rename a particular sheet in Google sheet?

Touch a worksheet tab at the bottom of your screen to select the sheet so that you can get started changing it. On Android tablets and phones, a dialog box will ask you to enter the new sheet name. Press OK to confirm changes. On iOS devices, a cursor will appear letting you change the name directly on the tab.


1 Answers

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var tz = ss.getSpreadsheetTimeZone();
  var sheets = ss.getSheets();
  var date = Utilities.formatDate(new Date(), tz, 'MM-dd-yyyy');
  sheets[1].setName(date);  // Rename second
}

Reference

like image 139
Bryan P Avatar answered Sep 28 '22 01:09

Bryan P