Een familie van Microsoft-spreadsheetsoftware met hulpmiddelen voor het analyseren, in kaart brengen en communiceren van gegevens.
Hi,
I'm Sneha and I'd be happy to help you out with your question. Sorry for the inconvenience caused.
The Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) event is triggered only when a user clicks on a hyperlink and not when a cell contains the HYPERLINK formula.
One solution to achieve your desired result is to create a custom function that extracts the hyperlink address from the cell containing the HYPERLINK formula and then uses the FollowHyperlink method to open the hyperlink.
I have provided an example code below that you can use as a reference:
Function FollowHyperlinkFromFormula(rng As Range) If InStr(1, rng. Formula, "HYPERLINK(") > 0 Then linkLoc = Mid(rng. Formula, InStr(1, rng. Formula, Chr(34)) + 1, InStr(InStr(1, rng. Formula, Chr(34)) + 1, rng. Formula, Chr(34)) - InStr(1, rng. Formula, Chr(34)) - 1) ActiveWorkbook.FollowHyperlink linkLoc End If End Function
This function takes a range as input and checks if the range contains a HYPERLINK formula. If the range contains a HYPERLINK formula, the function extracts the hyperlink address and opens it using the FollowHyperlink method.
To use this function, you can call it from a cell by entering the formula =FollowHyperlinkFromFormula(A1) where A1 is the cell containing the HYPERLINK formula.
Please note that this approach may not work if the HYPERLINK formula is nested within other formulas or if the friendly name contains a quotation mark. In such cases, you may need to modify the function to handle these situations.
If you have any other questions or need assistance with anything, please don't hesitate to let me know. It will be my pleasure to Assist you.
Best Regards, Sneha
Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.