Consulting

Results 1 to 2 of 2

Thread: Solved: Automating Hyperlinks

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Location
    Kansas, land of Dorothy and Toto
    Posts
    36

    Solved: Automating Hyperlinks

    Is there a way to take a hyperlink from one column and assign it to the text in another column? We have an automated report that lists document names in column B and a link to the document in column D. I need to have the link from D assigned to the title in B for each line in the spreadsheet so I can tranfer that data to a Word document and publish it as an htm file.

    Marci

  2. #2
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    [vba]
    Sub Changelink()

    Dim aRng As Range, c As Range
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Set aRng = Range("B2:B8") 'set to correct range
    For Each c In aRng
    If Not c = "" Then
    With c.Hyperlinks
    If .Count = 0 Then
    .Add c, c.Offset(, 2).Text, , , c.Text
    Else
    .Delete
    .Add c, c.Offset(, 2).Text, , , c.Text
    End If
    End With
    End If
    Next c
    Application.EnableEvents = False
    End Sub
    [/vba]
    This will do it. Just change the variable aRng to be your range of column B.

    Macro and result attached.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




Posting Permissions

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