Solved

Change and Add Hyperlinks in Excel

Posted on 2016-10-02
6
50 Views
Last Modified: 2016-10-04
I have an Excel worksheet with a column needs to hyperlinked with PDF files in the same folder, the column text has the same PDF file name.
1) Is it possible to Hyperlink all without going one by one ?
2) Also there are some text in the sheet already Hyperlinked and  needs to be changed ?
3) If the folder has been moved to other path is it going to work ?

Thanks
0
Comment
Question by:m_jundi
6 Comments
 
LVL 9

Assisted Solution

by:Carlos Ijalba
Carlos Ijalba earned 50 total points
ID: 41825361
Hi m_jundi,

1)  you can writing a macro in vba that uses a table to update the addresses

2)  you cannot change that hyperlink with data>hyperlink>modify ?

3)  it is if you have used absolute paths, if you have used relative paths, you will have to change them and make them absolute, with this I mean:

Absolute: " \\SHARE\folder1\forlder2\document"
Relative: "..\..\document"

the absolute path will work on any PC with access to the share, the relative will only work when executed from the correct path.
0
 
LVL 8

Expert Comment

by:Koen
ID: 41825373
try following code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("C2").Select
    Do While ActiveCell <> ""
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
        ActiveCell.Value
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub

Open in new window


Where your URL's are in column 3.
It will overwrite any existing url's
0
 

Author Comment

by:m_jundi
ID: 41825914
Koen,
1) as Carlos Ijalba advised do we need to change it to absolute paths ?
2) We need to add PDF extensions as the example shown below
3 ) Also advise if there are things need to be changed in the Macro except the the range

Example :
Column "F" DATA
A (Hyperlinked to A.PDF)
B (Hyperlinked to B.PDF)
C (Hyperlinked to C.PDF)

Thanks
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 32

Expert Comment

by:Rob Henson
ID: 41825957
If you use the HYPERLINK function you can create a hyperlink within the cell with variable inputs.

Syntax is:

=HYPERLINK(Link_Location, Friendly Name)

The Link Location can be put together as a string from various inputs using text functions. The Friendly Name is what appears in the cell and can be also be a cell reference.

Thanks
Rob H
0
 
LVL 8

Accepted Solution

by:
Koen earned 450 total points
ID: 41827115
I've adjusted the code... you now have 3 lines reading Mylink = ... you should only use one depending on the location of the files you are trying to link... (comment or delete the others)

and to answer your questions, yes absolute paths is always better; ".pdf" is added in the code below; I've changed the column to F per your data model...
should run fine...

Sub Macro3()
'
' Macro3 Macro
'

'
    Range("F2").Select
    Do While ActiveCell <> ""
    MyLink = "C:\directory\" & ActiveCell.Value & ".pdf" 'if the file is on the local machine
    MyLink = "\\Server\Directory\" & ActiveCell.Value & ".pdf" 'if the file is on a share
    MyLink = "https://yoursharepoint.com/site/library/" & ActiveCell.Value & ".pdf" 'if the file is on a sharepoint
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=MyLink
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub

Open in new window

1
 

Author Closing Comment

by:m_jundi
ID: 41827561
Thanks Koen, Perfect
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question