jeffreybrown
Well-known Member
- Joined
- Jul 28, 2004
- Messages
- 5,152
I've seen this before but can't seem to locate it.
I would like to pull files from a directory into column A and then from column B I will rename those files and then I would like to rename the files from what is in column B.
Here is the code which I use to capture the file names in column A.
I would like to pull files from a directory into column A and then from column B I will rename those files and then I would like to rename the files from what is in column B.
Here is the code which I use to capture the file names in column A.
Code:
Sub ListFilesNames()
Dim strTemp As String, MyPath As String, myFile As String
Dim intCount As Integer, f()
intCount = 0
MyPath = ActiveWorkbook.Path & Application.PathSeparator
myFile = "*.*"
strTemp = Dir(MyPath & myFile)
Do While strTemp <> Empty
intCount = intCount + 1
ReDim Preserve f(1 To intCount)
f(intCount) = strTemp
strTemp = Dir
Loop
With Sheets("Sheet1")
.Range("A:A").Clear
.Range("A1").Resize(UBound(f), 1).Value = WorksheetFunction.Transpose(f)
End With
End Sub