Excelmacros以获取特定文件夹修改中的文件链接列表

我有一个macros允许用户select一个文件夹,并将该文件夹中的文件列为链接。 但是,这个列表从A1单元格开始,但是我点击了单元格I5,并且希望列表在我单击的单元格处开始。 如何修改下面的macros:

Sub GetFileNames() Dim xFSO As Object Dim xFolder As Object Dim xFile As Object Dim xFiDialog As FileDialog Dim xPath As String Dim I As Integer Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker) If xFiDialog.Show = -1 Then xPath = xFiDialog.SelectedItems(1) End If Set xFiDialog = Nothing If xPath = "" Then Exit Sub Set xFSO = CreateObject("Scripting.FileSystemObject") Set xFolder = xFSO.GetFolder(xPath) For Each xFile In xFolder.Files I = I + 1 ActiveSheet.Hyperlinks.Add Cells(I, 1), xFile.Path, , , xFile.Name Next End Sub 

非常感谢你的专业知识!

羽毛这在你的macros:

 Dim curCell As Range Set curCell = ActiveCell i = 0 For Each xFile In xFolder.Files ActiveSheet.Hyperlinks.Add Cells(curCell.Row + i, curCell.Column), xFile.Path, , , xFile.Name i = i + 1 Next 

当你运行macros时,它会查看活动单元格,然后使用该列和行开始。