I am using the HYPERLINK function to create a dynamic URL using a formula.
As a simplified example, it would look something like this:
=HYPERLINK("http://baseurl.com/"&4+4, "testlink8")
I can use the UDF below to successfully extract the text portion of the URL but of course it does not evaluate the expression (4+4) and returns http://baseurl.com/, the text between the quotes in the formula, instead of the desired result of http://baseurl.com/8.
I suspect I need to use the EVALUATE function to evaluate the formula before trying to extract the URL but unfortunately my Excel skills are not currently to the task. Can anyone help, please?
As a simplified example, it would look something like this:
=HYPERLINK("http://baseurl.com/"&4+4, "testlink8")
I can use the UDF below to successfully extract the text portion of the URL but of course it does not evaluate the expression (4+4) and returns http://baseurl.com/, the text between the quotes in the formula, instead of the desired result of http://baseurl.com/8.
I suspect I need to use the EVALUATE function to evaluate the formula before trying to extract the URL but unfortunately my Excel skills are not currently to the task. Can anyone help, please?
Code:
Function GetLink(HyperlinkCell As Range)
Dim s() As String
If Not HyperlinkCell.HasFormula Then Exit Function
s() = Split(HyperlinkCell.Formula, """")
GetLink = s(1)
End Function