I have the following code:
![]()
Sub attachyperlinks() Dim MyCell As Object Dim Link As String For Each MyCell In Selection If MyCell <> "" Then ActiveSheet.Hyperlinks.Add Anchor:=MyCell, Address:="C:\Users\folderA\folderB\log\" & MyCell.Value & ".pdf", ScreenTip:="Click to Open" End If Next MyCell MsgBox ("Hyperlinks attached successfully.") End Sub
Which attaches a hyperlink to the selected cells using cell contents are filename.
What i now need to add is code to make it check if the file exists first before adding the hyperlink. If the file is not there then the hyperlink should not be added ie leave cell contents as is.
Can someone please advise me?
Bookmarks