Rename a sheet in Google Sheets using Apps Script

Updated February 09, 2025

In this tutorial, I will show you how to rename a sheet in a Google Sheets spreadsheet using Apps Script. This is actually very easy to do and the Apps Script code is just a couple of lines long.

The function renameSheet() accepts two parameters: (1) the current name of the sheet and (2) its new name.

First, we get a reference to the sheet by using the getSheetByName(currentName) method of the Sheet class and then we rename it using the setName(newName) method.

function renameSheet(currentName, newName) {
 // Get a reference to the sheet using its existing name
 // and then rename it using the setName() method.
 SpreadsheetApp.getActive().getSheetByName(currentName).setName(newName);
}

To use the function, just call it with the sheet's current and new name.

renameSheet("hr", "Human Resources");

Conclusion

In this tutorial, I showed you how to rename a sheet in a Google Sheets spreadsheet using Apps Script.

Thanks for reading!

DISCLAIMER: This content is provided for educational purposes only. All code, templates, and information should be thoroughly reviewed and tested before use. Use at your own risk. Full Terms of Service apply.