目录列表超链接macros需要移动到另一列

所以在今天早些时候我得到了我的代码修复超链接,但我似乎无法弄清楚如何得到它把列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 

原谅索引中的随机单词,由于在另一个macros中使用通常的单词,我不得不将它们改成奇怪的名字。

基本上,

 dim linger as integer 

 'Get the row at which to insert Linger = Range("A65536").End(xlUp).row + 1 

给我列A没有mater我放在那里,有人可以帮助我得到这个超链接列U列?

U保持索引21

所以replace

 ActiveSheet.Hyperlinks.Add Anchor:=Cells(Linger, 1), Address:=Way, TextToDisplay:=Enigma 

 ActiveSheet.Hyperlinks.Add Anchor:=Cells(Linger, 21), Address:=Way, TextToDisplay:=Enigma 

你应该能够在U列中获得你的超链接


请参阅使用“ Cells对象时的第一个参数是行号,第二个参数是列号。

因此, Cells(1,1)对应于与Range("A1")相同的Range("A1")

Cells(linger,21)将无论什么样的linger值在列U

要么

Range("U" & linger)将是一个替代