Consulting

Results 1 to 3 of 3

Thread: hyperlink path with string

  1. #1

    hyperlink path with string

    Hello!

    I have a sheet filled with around 100 rows of data. In each row the first cell has a six digit long number in it, and there is a folder, with word files, with the same name for each and every one.
    I would like to make a makro, wich goes through all of them and hyperlinks the document with to the cells with matching name.
    Im thinking about something like getting the name from the cell, and inserting that to the address of the hyperlink, but don't know how.

    Sub hyperlinks()
    Worksheets(Worksheets.Count).Select
    Dim nev As String
    nev = "L:\BC-Development\08_R_BCX31\Projects\RED - 1525, 1555 - BCD31\Specifications\156727.doc"
    ActiveCell(A2).Select
    ActiveCell.Hyperlink.Add Anchor:=Selection, Address:="", SubAddress:=nev
      
    End Sub
    this is a code i wrote, to test if its even possible to use a string to give a path to a hyperlink, but doesn't seem to work.
    Anyone with any idea?
    Thank you!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Sub Test()
        Dim nev As String
        Dim cel As Range
        nev = "L:\BC-Development\08_R_BCX31\Projects\RED - 1525, 1555 - BCD31\Specifications\"
        For Each cel In Selection
        ActiveSheet.Hyperlinks.Add Anchor:=cel, Address:=nev & cel & ".doc"
        Next cel
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Hey!
    Sorry for the delayed answer.
    Your code worked perfectly! Thanks a lot!
    Best wishes

Posting Permissions

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