In this post, you’ll learn how to rename a File in Excel VBA using Name command.
Rename a File in Excel VBA
In Excel VBA, to rename an existing file, you can use the Name Command.
To rename a file using Name command,
- Firstly you need to locate the file in the local directory.
- Copy the location address of the file.
“C:\Excel VBA\Excel VBA 2.xlsx”
Enter the following code in the Visual Basics editor,
Name "C:\Excel VBA\Excel VBA 2.xlsx" As "C:\Excel VBA\Renamed File.xlsx"
- Run the codes.
- Now go to the directory, you can see the file name changed.