Hello,
I'm trying to alter this code a bit to fit an existing template. I'm having issues with the following:
1. I need the files to be listed starting in cell B11. I have been able to get it to start in B1, but not B11
2. Am I able to add the file path starting in C11, File Type in D11, and Modified Date in E11? (Not super necessary, but it would just fit nicely in existing template)
3. Instead of having the file path in the code, can I have it reference a cell that has the file path in it? In the template, we currently drop the file path in cell C7 and the current macro reads that.
The current macro is very slow so I'm trying to alter this code because it is exponentially faster. Complete overhaul!
Sub ListAllFileNames()
Dim strTargetFolder As String, strFileName As String, nCountItem As Integer
' Initialization
nCountItem = 1
strTargetFolder = "file path" & "\"
strFileName = Dir(strTargetFolder, vbDirectory)
' Get the file name
Do While strFileName <> ""
If strFileName <> "." And strFileName <> ".." Then
Cells(nCountItem, 2) = strFileName
nCountItem = nCountItem + 1
End If
strFileName = Dir
Loop
End Sub
Any help is very much appreciated!
I'm trying to alter this code a bit to fit an existing template. I'm having issues with the following:
1. I need the files to be listed starting in cell B11. I have been able to get it to start in B1, but not B11
2. Am I able to add the file path starting in C11, File Type in D11, and Modified Date in E11? (Not super necessary, but it would just fit nicely in existing template)
3. Instead of having the file path in the code, can I have it reference a cell that has the file path in it? In the template, we currently drop the file path in cell C7 and the current macro reads that.
The current macro is very slow so I'm trying to alter this code because it is exponentially faster. Complete overhaul!
Sub ListAllFileNames()
Dim strTargetFolder As String, strFileName As String, nCountItem As Integer
' Initialization
nCountItem = 1
strTargetFolder = "file path" & "\"
strFileName = Dir(strTargetFolder, vbDirectory)
' Get the file name
Do While strFileName <> ""
If strFileName <> "." And strFileName <> ".." Then
Cells(nCountItem, 2) = strFileName
nCountItem = nCountItem + 1
End If
strFileName = Dir
Loop
End Sub
Any help is very much appreciated!