Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    May 2001
    Location
    Kenilworth, Warwickshire, England
    Posts
    269
    Thanks
    3
    Thanked 0 Times in 0 Posts

    extract hyperlinks from cell (office 2000)

    I have a colleague who is manually going through a very large file. lets say col A contains some text and a hyperlink to somewhere. Col B is empty. he is right clicking on a cell in col A, editing the hyperlink, copying it and then pasting the target into col B. I cannot believe that it is necessary to do this by hand. We tried a macro to mimic his actions, but it ends up with absolute cell references and no mouse arrow key movements, so we cant get it to go down the column. We cant find a function to do the job.

    Any ideas please

    Mike C

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: extract hyperlinks from cell (office 2000)

    You could create a custom function:
    <code>
    Public Function GetAddress(rng As Range) As String
    On Error Resume Next
    GetAddress = rng.Hyperlinks(1).Address
    End Function
    </code>
    Say that the hyperlinks start in A1. Enter the following formula in B1:
    <code>
    =GetAddress(A1)
    </code>
    and fill down (for example by double clicking the fill handle in the lower right corner of B1).

    Note: if you put the function in your Personal.xls, the formula becomes
    <code>
    =Personal.xls!GetAddress(A1)</code>

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: extract hyperlinks from cell (office 2000)

    Something like this perhaps? This puts the hyperlink address in the cell directly to the right of each hyperlink on a sheet.

    <pre>Option Explicit
    Sub ExtractHL()
    Dim HL As Hyperlink
    For Each HL In ActiveSheet.Hyperlinks
    HL.Range.Offset(0, 1).Value = HL.Address
    Next
    End Sub</pre>


    [Note: there is also a HL.subaddress that might be "copied" also if you are linking to a part of the file and it could be easily modified to loop through all worksheets in the workbook...]

    Steve

  4. #4
    3 Star Lounger
    Join Date
    May 2001
    Location
    Kenilworth, Warwickshire, England
    Posts
    269
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: extract hyperlinks from cell (office 2000)

    Hans,

    again, many thanks. My colleague is really excited about the solution which works perfectly, and about the whole Woody process. I think we have another convert to the Lounge

    cheers,

    Mike C

  5. #5
    3 Star Lounger
    Join Date
    May 2001
    Location
    Kenilworth, Warwickshire, England
    Posts
    269
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: extract hyperlinks from cell (office 2000)

    Thank you very much for your reply / advice. Hans just got in first and his worked, but we will try to understand yours when a spare moment arrives. As I said to Hans, the whole process so impressed my colleague that I think we have another member coming up!

    Cheers

    Mike C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •