本工作簿所在的文件夹里所有xlsx文件列到A列并形成超链接
Sub Sample() Dim MyName As String, MyPath As String Dim i As Long MyPath = ThisWorkbook.Path & "\" MyName = Dir(MyPath & "*.xlsx") Do While MyName <> "" i = i + 1 Cells(i + 1, 1) = MyName ActiveSheet.Hyperlinks.Add Anchor:=Cells(i + 1, 1), Address:=MyName MyName = Dir Loop End Sub
效果: