How to Rename a File in Excel VBA?

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.
How to Rename a File in Excel VBA?

“C:\Excel VBA\Excel VBA 2.xlsx”

Enter the following code in the Visual Basics editor,

Code:

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. 
How to Rename a File in Excel VBA?

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this article, you will learn about the SKEW.P function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the SKEW function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the RANK.EQ function, the formula syntax and usage of the function in Microsoft...
  • Excel
  • November 23, 2021