PDA

View Full Version : [SOLVED] hyperlink path with string



mtkalman
06-12-2017, 01:30 AM
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!

mdmackillop
06-12-2017, 03:04 AM
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

mtkalman
06-26-2017, 02:15 AM
Hey!
Sorry for the delayed answer.
Your code worked perfectly! Thanks a lot!
Best wishes