Hello, I am trying to hyperlink pdf files in each row that will have a variable in the filename, or may not exist yet.
I have the exact file path in column K for each row. The file name will be in Column H plus specific Text and then may or may not have additional characters.
I put the Specific Text in Column A.
I got this code from previous posts and I think its almost what will work, I just can't figure out how to change the File path to Column K for each row. A little help please? I'm learning.
I have the exact file path in column K for each row. The file name will be in Column H plus specific Text and then may or may not have additional characters.
I put the Specific Text in Column A.
I got this code from previous posts and I think its almost what will work, I just can't figure out how to change the File path to Column K for each row. A little help please? I'm learning.
VBA Code:
Option Explicit
Sub CreateHyperlink()
Dim lRow As Long
Dim Path As String
Dim File As String
Dim Ext As String
Dim r As Range
lRow = Cells(Rows.Count, "A").End(xlUp).Row
Ext = "*.pdf"
Path = "C:\Users\YourPath\"
' Go through each cell in column D starting at 2
For Each r In Range("A2:A" & lRow)
File = Dir(Path & Ext)
If File Like "*" & r.Value & "*" Then
r.Hyperlinks.Add r, Path & File, , , r.Value
End If
File = Dir()
Next r
End Sub