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 post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...