Extracting Urls into another column.

  • Thread starter Thread starter rafter
  • Start date Start date
R

rafter

Hi, as a web developer I often have a list of Links that i need to work
on.
When I copy from a webpage and paste into Excel I get the Linktexts
(ie. _MY_WEBSITE_ ) and would like to have the Url (Webadress) 'behind'
this text in another column (ie. www.mywebsite.com).
The macro I have managed only copies the Linktext (with the recording
function)

Thanks for any help!
 
You could write your own (a userdefined function).

I used ctrl-K (insert|Hyperlink) to create the link:

Option Explicit
Function GetURL(Rng As Range) As String
Application.Volatile

Set Rng = Rng(1)

If Rng.Hyperlinks.Count = 0 Then
GetURL = ""
Else
GetURL = Rng.Hyperlinks(1).Address
End If
End Function

So if you had a hyperlink in A1, you could put =getURL(a1) in that adjacent
cell.

Be aware that if you change the hyperlink, then this formula cell won't change
until your workbook calculates.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top