We have a Google Sheet and the names of the Sheets will change based on the date. So, we will have a string of

  • Mon 2.15
  • Tue 2.16
  • Wed 2.17
  • Etc...

Sheet tab examples

The sheets are copied and then a new name given to them.

I have a script that was written to autopopulate the date and time if the cell to the right is modified. The code is

function onEdit() { 
    var s = SpreadsheetApp.getActiveSheet(); 
    if( s.getName() == "Testing Autopopulation" ) { 
        //checks that we're on Sheet1 or not var r = s.getActiveCell(); 
        if( r.getColumn() == 13 ) { 
            //checks that the cell being edited is in column M var nextCell = r.offset(0, -1); 
            //if( nextCell.getValue() === '' ) 
            //checks if the adjacent cell is empty or not? 
            nextCell.setValue(new Date()).setNumberFormat("MM/dd HH:mm"); 

What would I need to add to make it so that the Sheet name can change?

  • Welcome to Web Applications. I'm sorry, I don't understand what are you asking. Please add some examples. Commented Feb 9, 2021 at 3:42
  • For example: Users would create a new Sheet every day and the sheet names would be similar to: Wed 2.16 Thu 2.17 Fri 2.18 The script goes by the name of the Sheet. I don't want to keep modifying the script when the name of the Sheet changes. There are also other Sheets in this with different names. Does that help? I will try to attach an image with the Sheet tabs.
    – Joe
    Commented Feb 9, 2021 at 15:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.