1

Is it possible to dynamically change the name of a sheet in Google Sheets based on the contents of a specific cell? For instance, I'd like my sheet to get its name from whatever is in cell A1... is that possible at all?

  • Yes! It's possible. Start reading Extend Google Docs, Sheets, and Forms with Apps Script - Docs editors Help – Rubén Sep 8 '15 at 11:11
  • @Rubén Awesome! But do you mean I would need to script it myself (possible, but not right now, since I really don't have the time to learn for another 2-3 weeks), or that there is a specific add-on or script hidden on that site somewhere? – Alicja Z Sep 8 '15 at 11:30
  • I meant that you should read the referred article to learn the basics about what is possible with Google Sheets. That will help you to learn words and terms that you could use to find add-ons and scripts and to reword your question. Bear in mind that this site isn't for asking about web apps recommendations. Anyway, I think that there should be somewhere an add-on or script. Have you already tried to find them? Another recommended reading: How do I write a great question?. – Rubén Sep 8 '15 at 12:07
  • @Rubén Thanks for suggesting I learn how to ask better questions, though I'm unclear as to how I could've improved mine - turns out I couldn't have done half-bad if Normal Human understood me and suggested a perfect solution... I did, in fact, spend a good few hours looking for scripts and add-ons and tried my hand at coding awkwardly - and only turned to SE after coming up with no working solution on my own. I guess I should've mentioned "I failed at finding something myself" in my question - but I assumed that was a given? Seems SE is less welcoming than some of the SO sites I frequent... – Alicja Z Sep 9 '15 at 13:44
3

Here's a script that does this: enter it in Tools > Script Editor.

It runs automatically on every edit, and renames the active sheet if the content of A1 (referred by row 1, column 1) does not match the current sheet name.

function onEdit() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var oldName = sheet.getName();
  var newName = sheet.getRange(1,1).getValue();
  if (newName.toString().length>0 && newName !== oldName) {
    sheet.setName(newName);
  }
}

That said, I think this is not a particularly good way of naming sheets.

  • Awesome, thank you! I know, it's typically really a bad idea, but in this specific case, it's exactly what's needed, since 15+ sheets need to change names yearly (and this across a number of spreadsheets, I'm sure), so this is beyond awesome. – Alicja Z Sep 9 '15 at 13:33
  • So, I've successfully implemented this script onto a spreadsheet of my own but I have one issue with it that I can't seem to get around. I have it set up so that the sheet name corresponds to a cell containing a date. Whenever the sheet name is updated it comes out like this : "Fri Feb 08 2019 00:00:00 GMT-0000 (GMT)" whereas the cell only contains the following: "08/02/19" Any way to have the sheet only display what is actually displayed in the cell? – JonatanOlsson Dec 2 '18 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.