Saturday, June 26, 2010

UDF to Extract Hyperlink Address from Cell


If you want to extract hyperlink address from a cell. Try this udf-

Function hyperlink_extcell(cell As Range)
    If cell.Hyperlinks.Count > 0 Then
        If Not cell.Hyperlinks(1).Address = vbNullString Then
            hyperlink_extcell = cell.Hyperlinks(1).Address
        Else
            hyperlink_extcell = cell.Hyperlinks(1).SubAddress
        End If
    Else
        hyperlink_extcell = "Hyperlink Not Found"
    End If
End Function

Download Working File


Steps to Use

  • Copy the below code
  • Press Alt+F11 to open VBA editor
  • Paste it in any public module or module 1
  • For example you want to extract Hyperlink from cell A1 in Cell B1 . In B1 = hyperlink_extcell(A1)

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...