Suppose I have a hyperlink in cell A1: =hyperlink("stackexchange.com", "Stack Exchange")
Elsewhere in the sheet, I'd like to have formulas that get the link text and URL from A1, separately. I found a way to get just the link text:
=""&A1
(concatenation with empty string). This returns "Stack Exchange", unlinked.
How to get the URL (stackexchange.com)?
Best Answer
After seeing Rubén's answer I decided to write a different custom function for this task, with the following features:
=linkURL(C2)
instead of=linkURL("C2")
. This is consistent with how parameters usually work, and makes the references more robust: they will be maintained if someone adds a new row on top.=linkURL(B2:D5)
returns the URLs of allhyperlink
commands found in this range (and blank cells for other places).To achieve 1, I do not use the argument passed by the sheet (which would be the text content of the target cell), but instead parse the formula
=linkURL(...)
itself and extract range notation from there.