Could somebody please explain what I have got wrong with this bit of code.
I am trying to search through folders & subfolders for a folder named the same as the unique value in the selected range.
Once it finds the folder I then want to insert a hyperlink for that folder in the corresponding value in the selected range, then next until all the selected cells are hyperlinked to the relevant folders
I am getting the error "Invalid Qualifier" & it’s highlighting "Filepath" in this line of code
In testing stage at present, so I'm not sure if it actually works yet as I can't get past this error, MS Help totally confused me.
Full code below
All help as always appreciated
I am trying to search through folders & subfolders for a folder named the same as the unique value in the selected range.
Once it finds the folder I then want to insert a hyperlink for that folder in the corresponding value in the selected range, then next until all the selected cells are hyperlinked to the relevant folders
I am getting the error "Invalid Qualifier" & it’s highlighting "Filepath" in this line of code
VBA Code:
For Each SubFolder In FilePath.SubFolders
Full code below
All help as always appreciated
VBA Code:
Sub InsertHyperlinks() 'need to get it to search subfolders
Dim FilePath As String
Dim FldrName As String
Dim c As Range
Selection.Hyperlinks.Delete ' clearing any old hyperlinks from selected cells
FilePath = "U:\QC Document Controller\Test\"
For Each SubFolder In FilePath.SubFolders
For Each c In Selection
FldrName = (c.Value)
If FldrName <> "" Then
ActiveSheet.Hyperlinks.Add Anchor:=c, Address:=FilePath & c.Value, TextToDisplay:=c.Value
End If
Next c
Next
End Sub
Last edited: