Excel VBA-If partial match in file names, generate hyperlink - TechRepublic
Question
October 3, 2019 at 01:15 PM
acatk

Excel VBA-If partial match in file names, generate hyperlink

by acatk . Updated 6 years, 8 months ago

Hey Wizards,

On Excel spreadsheet:
A3 has a path to folder, like C:\Users\Auser\Documents\FolderA\
Cells A6 & down have a list of values, like 00K12345 per cell

Folder from path in A3 has files named as such: 12 201**002 ABC123 00K12345.PDF

Need: in corresponding cells in B6 & down:
If value from A is found in one of the files in A3 folder
Then generate hyperlink to it with value from A as friendly name
Otherwise populate “Not found”

So far only have the below code which returns true/false if link is valid, but obviously that doesn’t get it done

Code:
Function HLinkTrueFalse(path As String) As Boolean
If Dir(path) <> vbNullString Then HLinkTrueFalse = True
End Function

All Comments