本文件夹中的工作簿目录(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
效果:
标签:Dim,Sub,xlsx,Excel,MyName,文件夹,MyPath,目录,String 来源: https://www.cnblogs.com/officeplayer/p/15830563.html