Excel VBA Copy and Rename Files in Folder and Subfolders

This request came from a subscriber who was looking for a macro to rename files in a given folder, and make a copy of the renamed file within the same folder.  Once the files in the top level folder were processed, then cycle through each subfolder and do the same.  The following macro will accomplish this task, and has been setup to read file types of “.pdf” format.

If you are looking for content that does not exist on my blog, please submit a request through the “Contact” page.

Excel Version:  2013

OS:  Windows 10

Excel VBA Copy and Rename Files in Folder and Subfolder – Setup

For this macro, there are three folders:

Top-level folder:

Excel VBA Copy and Rename Files in Folder and Subfolders

Sub-folder “TestFilesSub”:

Excel VBA Copy and Rename Files in Folder and Subfolders

Sub-folder “TestFilesSubTwo”:

Excel VBA Copy and Rename Files in Folder and Subfolders

 

Add the macro code below:

Run the macro, and you will now see a copy of each file, renamed with a pre-fix file name of “Copy of – [Original File Name]”, in the top-level folder and each subfolder beneath:

Top-level folder:

Excel VBA Copy and Rename Files in Folder and Subfolders

Sub-folder “TestFilesSub”:

Excel VBA Copy and Rename Files in Folder and Subfolders

Sub-folder “TestFilesSubTwo”:

Excel VBA Copy and Rename Files in Folder and Subfolders

 

Please modify the macro to suit your needs!

 

 

 

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering Qlikview SQL Server Excel VBA

 

 

Leave a Comment