View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
ShaneDevenshire ShaneDevenshire is offline
external usenet poster
 
Posts: 2,344
Default converting hyperlink to actual web address

Hi,

Here is a function you can enter in the spreadsheet

Function myHyperlink(cell As Range) As String
On Error Resume Next
If cell.Hyperlinks(1).Address < "" Then
myHyperlink = cell.Hyperlinks(1).Address
ElseIf Err < 0 Then
myHyperlink = ""
Else
myHyperlink = cell.Hyperlinks(1).Name
End If
End Function

If your hyperlink is in cell A1 then in B1 enter =myHyperlink(A1)

This function returns a hyperlink address if there is one, otherwise if the
cell has a hyperlink that is not a typical hyperlink address it returns the
name. Finally if there is no hyperlink in the cell it return nothing.

If you want a macro to enter the hyperlink in the cell without a formula, then

Sub HLinks()
Dim cell As Range
On Error Resume Next
For Each cell In Selection
If cell.Hyperlinks(1).Address < "" Then
cell.Offset(0, 1).Value = cell.Hyperlinks(1).Address
ElseIf Err = 0 Then
cell.Offset(0, 1).Value = cell.Hyperlinks(1).Name
End If
Next cell
End Sub

To execute this macro you select all the cells with/without hyperlinks and
run it, the macro will populate the cell to the right similar to the function
above but it will not be a formula.
--
Thanks,
Shane Devenshire


"Roger on Excel" wrote:

Yes please Shane - that would work for me.

Thanks,

Roger

"ShaneDevenshire" wrote:

Hi,

I believe you would need to create a VBA routine to do this, do you want that?

--
Thanks,
Shane Devenshire


"Roger on Excel" wrote:

I have hyperlinksin a column in my spreadsheet.

I would like the cells adjacent to show the actual web address.

How do i do this?

Thanks in advance,

Roger