1

It's come to my attention that GoogleClock no longer works on new sheets, anyway I can update the below code so it can update every minute:

Tried put =SheetNames(NOW())

It says not allowed. I'm very new to scripts, below script I found on here:

function SheetNames() { // Usage as custom function: =SheetNames( GoogleClock() )
   try {
     var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
     var out = new Array( sheets.length+1 ) ;
     //out[0] = [ "Name" , "gid" ];
     for (var i = 3 ; i < sheets.length+1 ; i++ ) out[i-7] = [sheets[i-1].getName()];
     return out
    }
    catch( err ) {
       return "#ERROR!"
       SheetNames.flush();
    }
}

1 Answer 1

0

Google Sheets custom functions are recalculated when the spreadsheet is opened and when one of it's arguments changes but as you already noticed, volatile functions like NOW() aren't allowed.

Try this

=SheetNames(A:Z)

Where A:Z is a reference encompassing all the sheet columns, so when any cell is changed the custom function will be recalculated.

NOTES

  1. remove SheetNames.flush(); as flush() isn't a method of SheetNames. If you keep it, it will throw an error.
  2. If your sheet is recalculated too often or too many times on a day SheetNames could throw an error due to exceeding a quota.

Your Answer

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

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