i have a workbook in excel and in one column i am putting the names of images.
i want to create a macro/vba code so that when i type in the file name into the column e.g. IMG_1234 it will automatically be hyperlinked to a file such as file:///\public\Pictures\IMG_1234.JPG
Then when someone clicks on the link it will load a new window with the picture displayed.
I have found some code that answers my question in a Macro...however I wonder if it is possible to do this so it updates automatically rather than having to run the Macro every time...
Sub PictureLink() MyPath = "\\\public\Pictures\" StartRow = 8 EndRow = 200 MyEnd = ".JPG" x = 0 For i = StartRow To EndRow If Len(Cells(i, 4).Value) > 0 Then MyFileName = "" MyFileName = Dir(MyPath & Cells(i, 4).Text & MyEnd, vbNormal + vbDirectory) If MyFileName <> "" Then x = x + 1 ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 4), _ Address:=MyPath & Cells(i, 4).Text & MyEnd End If End If Next i End Sub
Hopefully someone can help me to modify this so it does it automatically.
Thanks a lot