Link Multiple Files in Excel

Sub AddHyperlinks()
Dim Cell As Range
Dim FSO As New FileSystemObject
Dim filePath As String
Dim fileName As String
Dim actualFile As String
Dim Length As Integer
Dim myFile As File
Dim myFolder As Folder
filePath = ThisWorkbook.Path & Application.PathSeparator
For Each Cell In selection
Set myFolder = FSO.GetFolder(filePath)
For Each myFile In myFolder.Files
Length = Len(Cell.Value)
actualFile = Left(myFile.Name, Length)
If actualFile = Cell.Value Then
ActiveSheet.Hyperlinks.Add Anchor:=Cell, Address:=myFile
End If
Next myFile
Next Cell
End Sub




Accounting Analyst at CMS Energy

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Data Science fwdays’20 conference| NLP discussion

Graph Query Searches (Part 3)

Spark and Oracle Database

Sense Making Under Crisis

A Supercomputer Analyzed Covid-19and an Interesting New Theory Has Emerged

Rankings & Rarities On TIEXO: Understanding Our Calculation

This career skill will change the way you think about reading.

Fighting crime with data and innovation

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thiago Cabral

Thiago Cabral

Accounting Analyst at CMS Energy

More from Medium

Setup python development environment with VSCode.

Scrape Apple Store Reviews with Python

Send Automatic mail using pyautogui

Journey of DLithe Bootcamp .NET Full Stack Week 2(Jan31-Feb5)