I'm using this script to return the ID of an open spreadsheet:
function getId() {
SpreadsheetApp.getActiveSpreadsheet().getId()
}
In the cell, I've added:
=getId()
The problem is, when I copy the spreadsheet, the new spreadsheet returns the ID for the original spreadsheet - not the ID for the active sheet.
If I enter =getId() in a new cell in the active sheet, it returns the correct ID. So the script is apparently working, it's not just not 'refreshing' the data for a copied sheet.
(Bizarrely, this has worked before! I don't know what's changed but it's stopped returning a new ID value.)
Can anyone suggest how to make sure the ID for the active sheet is shown?