Excel Create Folder per File Type | VBA Macro #64

Macro Intro

At home you open a messy closet and think to yourself how am I supposed to find anything in here! Similar situation you open a Folder on your computer and see different Files scattered all over. While we can’t automate the application of 5s for your closet we have plenty of opportunities to do so on your computer! This macro will navigate to the Folder path that you indicate in the VBA code looping through all files that are not within a Folder. For each unique File Type found a NEW Folder will be created moving any files of that type into that Folder. If you want to take this macro to the next level you can subscribe as an Insider gaining additional VBA Code that will allow you to list out multiple Folder Paths directly in the Excel Workbook. Below the Folder Paths you will also be able to list NEW Folders you want created and Files with specific File Extensions you want to be moved into each respective Folder. Example is all Excel Workbooks are moved into one Folder instead of .xlsx and .csv files being placed into separate Folder. Any remaining Files found but not indicated in the Excel Workbook will have separate Folders created for their File Extension.

See it in Action

Watch this video to see this macro in action.

***Video coming soon!***


Here is the code for this macro. Make sure the following References are setup before running it: Visual Basic For Applications, Microsoft Excel 16.0 Object Library

Insider Content

Here is the Insider code for this macro. This code will allow you to setup an Excel Workbook to list multiple Folder Paths for this macro to loop through and manage what Files should go to what Folders! Make sure the following References are setup before running it: Visual Basic For Applications, Microsoft Excel 16.0 Object Library


These segments of code can be customized to personalize this macro.
Populate the FolderPath variable with the Folder Path where you want the macro to complete it’s creation of file type folders and move files to their respective NEW folder.
By Default the Create Folder Per File Type Macro will display a MsgBox upon completion. The MsgBox will display the total number of Folders created and the File Types used. If you would prefer to not see a MsgBox upon running this macro then remove this code line or make this MsgBox a comment.

First time using VBA?

The Developer Tab is an additional section of the ribbon when activated allows you access to Visual Basic in Applications like Access, Excel, Outlook, PowerPoint, Word.
Setup Now
Once the Developer Tab is available you will have the capability to update your security to allow Macros to run in the current application.
Setup Now
A sub of code is a collection of objects and variables. For the code to successfully run a library of references needs to be set.
Setup Now
Subscribe as an Insider to receive additional rights.
If you like our content and want to show your support tip us here!

Contact Us

Looking to improve your computer processes?
Leverage & Lean is here to help!

Powered By MemberPress WooCommerce Plus Integration

Free Macro

Start creating Less Clicks, More Results today!