VBA Rename File

Associated Files Download Links

VBA allows you to rename an existing file, using the Name command. In this tutorial, you will learn how to rename a specific file.

If you want to learn how to copy and rename a file, you can click on this link: VBA Copy File


Rename a File in VBA

We will show how to rename the existing file Sample file 1.xlsx in the folder VBA Folder. The folder with the file now looks like in Image 1:


Image 1. File in folder C:\VBA Folder


Here is the code which will rename the file:

After running the code, the file Sample file 1.xlsx is now renamed to Sample file 2.xlsx. The output is in Image 2:


Image 2. Renamed file in the folder C:\VBA Folder



You may also like some of this related content...

VBA allows you to check if a file or folder exists, using the Dir command.
VBA allows you to delete an existing file, using the Kill command. In this tutorial,
VBA allows you to choose a file to open using the Application.GetOpenFilename method. In this
VBA allows you to copy a file, using the FileSystemObject. In this tutorial, you will
VBA allows you to list all files from a folder, using the FileSystemObject. In this