Google-sheets – Write cell value based on the URL of another sheet

formulasgoogle sheetsgoogle-apps-script

Is there any way populate a cell in a Google sheet based on the value in the URL?

For example: If the hyperlink below was on sheetA and the link was clicked. Is there any way to get ?cell=english into a cell in sheetB?


Best Answer

The event of someone clicking a hyperlink embedded in a spreadsheet is not visible to the spreadsheet itself. It cannot trigger any changes. (Unless the link is to some web application which is programmed to modify the spreadsheet).

As for extracting the URL from a cell with =hyperlink formula - this can't be done with built-in Sheets functions, but there is a custom function (implemented in Google Apps Script) which does that: see Extract the link text and URL from a hyperlinked cell.