There are some times that I use Google Sheets instead of Numbers. One example is to create our weekly run sheets for church. A runsheet looks like this:
You will notice the tabs across the bottom of the spreadsheet. It was getting a bit tedious changing the tab name every week.
So I wrote/modified/hacked together (with some help from ChatGPT) a script to take the date from the spreadsheet and automatically update the name of the tab.
Here is the date picker in Google Drive:
All I need to do it pick the date and the spreadsheet name is updated.
Here’s the script.
function onEdit() {
var sheet = SpreadsheetApp.getActiveSheet();
var oldName = sheet.getName();
var cellValue = sheet.getRange(3,3).getValue();
var newName = Utilities.formatDate(cellValue, Session.getScriptTimeZone(), 'MMM dd');
if (newName.toString().length>0 && newName !== oldName) {
sheet.setName(newName);
}
}
Make sure the (3,3) represents the field where your date is.
To add the script go to ‘Extensions’ the Apps Script and paste it, then save it.
If you want to change it not to be a date but a text field, just paste the entire script into ChatGPT and say ‘change this to work with a text field instead of a date field’
Leave a Reply Cancel reply