Hello I have a an excel file with column "A" with old file name and Column "B" with new file names. Column "A" gives me full filename plus the extension e.g. "Sales.xlsm" but Column "B" only give me filename i.e. "Sales"
I used the following code to replace old file names with new. It worked but the files are not saved in Excel format i.e. they are saved as just files.
Sub RenameFiles()
For R = 1 To Range("A2").End(xlDown).Row
OldFileName = Cells(R, 1).Value
NewFileName = Cells(R, 2).Value
On Error Resume Next
If Not Dir(OldFileName) = "" Then Name OldFileName As NewFileName
On Error GoTo 0
Next
End Sub
How do I save the new file names in Excel format?
Thanks,
Arslan
I used the following code to replace old file names with new. It worked but the files are not saved in Excel format i.e. they are saved as just files.
Sub RenameFiles()
For R = 1 To Range("A2").End(xlDown).Row
OldFileName = Cells(R, 1).Value
NewFileName = Cells(R, 2).Value
On Error Resume Next
If Not Dir(OldFileName) = "" Then Name OldFileName As NewFileName
On Error GoTo 0
Next
End Sub
How do I save the new file names in Excel format?
Thanks,
Arslan