After searching through various questions and the documentation I still cannot edit the calling cell of a custom function. According to the docs:
Returns the range of cells that is currently considered active. This generally means the range that a user has selected in the active sheet, but in a custom function it refers to the cell being actively recalculated.
Although this description is for the getActiveRange() function one assumes the getActiveCell() functions in the same way.
I am trying to call a helper function from within my custom function which should return the 'active cell' which, to my knowledge, should be the calling cell of the custom function. Not working code:
// returns the current active (calling) cell for use within custom functions
function callingCell() {
return SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getActiveRange()
}
// change background colour of calling cell
function getInfoFromPublicApi(type) {
... // get prices using UrlFetchApp
callingCell().setBackground('green')
return averagePrice(prices, type)
}
I have also tried using the SpreadsheetApp from within the custom function directly, as well as using:
SpreadsheetApp.getActiveSpreadsheet().getActiveCell()
SpreadsheetApp.getActiveSpeadsheet().getActiveRange()