本文件夹中的工作簿目录(Excel代码集团)

本工作簿所在的文件夹里所有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

效果:

 

posted @ 2022-01-21 15:54  熬肥妖  阅读(96)  评论(0编辑  收藏  举报