3

Currently I am using this on a new added column to extract the hyperlink. How do I add code that will not enter any value (leaving it just blank) if there is no URL. Actually what I needed was when importing in PowerBI, those URL or hyperlink excel spreadsheet does not display the hyperlink after importing the data to PowerBI. I believe there is no way to do this but I thought PowerBI was powerful enough to detect this hyperlink in the spreadsheet.

    Function CopyURL(HyperlinkCell As Range)

CopyURL = HyperlinkCell.Hyperlinks(1).Address
End Function

2 Answers 2

0

try something like this:

If Range("HyperlinkCell") <>"" Then
    Function CopyURL(HyperlinkCell As Range)

CopyURL = HyperlinkCell.Hyperlinks(1).Address
End Function
Else 
End If

I'm basing this from vba so if it doesn't work let me know and I'll remove it

0

Consider:

Public Function CopyURL(HyperlinkCell As Range) As String
    If HyperlinkCell.Hyperlinks.Count = 0 Then
        CopyURL = ""
    Else
        CopyURL = HyperlinkCell.Hyperlinks(1).Address
    End If
End Function

Note:

This is for Inserted Hyperlinks not formulaic hyperlinks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .