所以今天早些时候我把我的代码固定为超链接,但我似乎不知道如何让它把列表放在 U 列而不是 A 列。
Sub hyperlinker()
Dim MOG As Object
Dim rsMOG As Object
Dim PrimeF As Object
Dim Bit As Object
Dim Foder As Object
Dim Linger As Integer
Dim Enigma As String
Dim Way As String
'Get the current folder
Set MOG = CreateObject("scripting.filesystemobject")
Set PrimeF = MOG.GetFolder(ThisWorkbook.Path)
Set MOG = Nothing
'Get the row at which to insert
Linger = Range("A65536").End(xlUp).row + 1
'Create the recordset for sorting
Set rsMOG = CreateObject("ADODB.Recordset")
With rsMOG.Fields
.Append "Way", 200, 200
.Append "Enigma", 200, 200
.Append "Bit", 200, 200
End With
rsMOG.Open
' Traverse the entire folder tree
TraverseFolderTree PrimeF, PrimeF, rsMOG
Set PrimeF = Nothing
'Sort by type and name
rsMOG.Sort = "Bit ASC, Enigma ASC "
rsMOG.MoveFirst
'Populate the first column of the sheet
While Not rsMOG.EOF
Enigma = rsMOG("Enigma").value
Way = rsMOG("Way").value
If (Enigma <> ThisWorkbook.name) Then
ActiveSheet.Hyperlinks.Add Anchor:=Cells(Linger, 1), Address:=Way, TextToDisplay:=Enigma
Linger = Linger + 1
End If
rsMOG.MoveNext
Wend
'Close the recordset
rsMOG.Close
Set rsMOG = Nothing
End Sub
Private Sub TraverseFolderTree(ByVal parent As Object, ByVal node As Object, ByRef rs As Object)
'List all files
For Each Bit In node.Files
Dim Enigma As String
Enigma = Mid(Bit.Path, Len(parent.Path) + 2)
rs.AddNew
rs("Way") = Way
rs("Enigma") = Enigma
rs("Bit") = "Bit"
rs.Update
Next
'List all folders
For Each Foder In node.SubFolders
TraverseFolderTree parent, Foder, rs
Next
End Sub
请原谅索引中的随机词,由于在另一个宏中使用了常用词,我不得不将它们更改为奇怪的名称。
基本上,
dim linger as integer
和
'Get the row at which to insert
Linger = Range("A65536").End(xlUp).row + 1
给我列A,不管我放什么,有人可以帮我把这个超链接列表放到U列吗?