I have a VBA program for importing all the file names in a target folder into a spreadsheet for manipulation. I am using this for managing architectural specifications. The program appears to work (monitoring variables) until the last step where it is to pass the data to the spreadsheet. At that point, it places the 1st cell of the array into the spreadsheet the once for each cell. Results shown below along with code.
VBA Code:
Public Sub GetFileNames()
Dim Result As Variant
Dim i As Integer
Dim MyFile, MyFso, MyFolder, MyFiles As Object
Dim FolderPath, FileExt As String
Dim outputarray As Variant
FolderPath = Worksheets("Sheet1").Range("A1").Value
Set MyFso = CreateObject("Scripting.FileSystemObject")
Set MyFolder = MyFso.GetFolder(FolderPath)
Set MyFiles = MyFolder.Files
ReDim Result(1 To MyFiles.Count)
i = 1
For Each MyFile In MyFiles
Result(i) = MyFile.Name
i = i + 1
Next MyFile
i = i - 1
Worksheets("Sheet1").Range(Cells(3, 1), Cells(3 + i, 1)).Value = Result
End Sub