OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for any suggestions which I will provide feedback.
I am making an Excel file where I place the directory path (Cell B3) of where files that I may want to rename are located.
It first obtains the file names and places them in Column A starting with Row 5.
I then place the new names in Column B starting in Row 5.
I get the error when I try to run the Macro to rename "Run Time Error 53: File not Found"
The following is the entire code to rename the files:
I am making an Excel file where I place the directory path (Cell B3) of where files that I may want to rename are located.
It first obtains the file names and places them in Column A starting with Row 5.
I then place the new names in Column B starting in Row 5.
I get the error when I try to run the Macro to rename "Run Time Error 53: File not Found"
Code:
Name DirFolderRename & CurrentName As DirFolderRename & NewName
The following is the entire code to rename the files:
Code:
Sub RenameFile()
'Dimensioning
Dim DirFolderRename As String
Dim CurrentName As String
Dim NewName As String
Dim i As Integer
i = 5
DirFolderRename = Sheets("List").Range("B3").Value
Do While Sheets("List").Cells(i, 1).Text <> "" And Sheets("List").Cells(i, 2).Text <> ""
CurrentName = Sheets("List").Cells(i, 1).Text <> ""
NewName = Sheets("List").Cells(i, 2).Text <> ""
Name DirFolderRename & CurrentName As DirFolderRename & NewName
i = 1 + 1
Loop
MsgBox ("Complete")
End Sub