Insert hyperlinks to all files in current folder
The macro creates a new sheet. Inserts all filenames in current folder as hyperlinks except the current workbook.
VBA Code
Sub InsertFilesInFolder()
Dim sPath As String, Value As String
Dim WS As Worksheet
Set WS = Sheets.Add
sPath = ActiveWorkbook.Path & "\"
Value = Dir(sPath, &H1F)
WS.Range("A1") = "Filename"
Set StartCell = WS.Range("A2")
Do Until Value = ""
If Value = "." Or Value = ".." Then
Else
If GetAttr(sPath & Value) = 16 Then
Else
If Value <> ActiveWorkbook.Name And Value <> "~$" & ActiveWorkbook.Name Then
StartCell.Hyperlinks.Add Anchor:=StartCell, Address:= _
Value, TextToDisplay:=Value
Set StartCell = StartCell.Offset(1, 0)
End If
End If
End If
Value = Dir
Loop
End Sub
Download excel *.xlsm file
Insert files in current folder.xlsm
Related posts:
Open excel files in a folder (vba)
Excel recursive udf: List files in a folder and subfolders
Follow hyperlinks in a pivot table
Identify duplicate files in excel
How to navigate quickly in a complex excel workbook using hyperlinks

















