Dear readers,
In my previous article I posted an article about how to create folder in windows by Excel VBA code. That triggers me to build an Excel tool to create a hierarchical or Tree folder structure in any directory which is defined by you in excel sheet. Before I built this tool, I was thinking what is TOP 3 problem is it going to solve of my readers and here are the answers:
1. Creating folder structure in No time
No matter how complex and how deep folder structure is, it will get created in seconds. To create folder structure, click on the “Create Now>>” button to do so.
Replicate any existing folder structure
Suppose you want to replicate an existing folder structure in your PC. So to do this, you can even copy the root folder and paste it – but there is a major disadvantage of this method. You are copying the files as well with the folder structure. You need to delete them all manually – which is a very time consuming and boring task. Using this tool you can simply read any existing folder structure and then by modifying the first root folder name, you can click on “Create Now>>” and folder structure is replicated without copying any content of the folder structure.
Define your own Folder structure templates
In big organizations when folder structure is left to individual choice then it becomes really messy as every one will try to organize the structure in a way they like. At the end each one of us are forced to browse each and every folder to find your document, which is not efficient. Therefore, it is a good practice to maintain a common folder structure across organization for each projects.
In such case all you can define your folder structure according to your need and save them as a template. Here on whenever there is new project, you can select that template and create the same folder structure for the new project.
Rules to Define Folder Structure here in Excel
Mainly there are 3 rules:
1. Your first Root Node should start from Range B10 as highlighted in the above picture as point no 9
2. Any of the child node can not be stated in the same row in next column.
3. Any of the row should not be blank.
How to use the tool
1 and 2. Main Folder Path and Browse button
This is path where you want to create your folder structure. This path can be typed manually or it can be selected by clicking on Browse button.
3 and 4. Existing Templates drop down and Load template
As explained above, in this tool you can define your own template. As soon as you have defined your template, you can see the name your new template in this drop down. After selecting the drop down, you need to click on Load Template button in order to display your defined structure.
5. Validate button
Validate button checks if all these 3 rules are satisfied in your defined structure or not. Unless these rules are met, it will not allow you to create your folder structure.
6. List existing Structure
By clicking on this button you can get the folder structure which is there at your given main folder path. Once your structure is loaded here in this sheet, now you can provide a different folder path and click on Create Now >> to create / replicate the same folder structure.
7. Create Now >>
As the name suggests, this is button which does the magic of creation of the defined folder structure.
8. Messages
In this field you will see all the messages/errors which occurs during any of the above operations.
9 and 10 – Labels header and First Node
Row 9 is defined to have the level headers and Cell B10 (name range= startRange) is the starting point where your first node should be specified.
How to define a new template
Steps are defined and explained in the Excel workbook itself in the template sheet. Kindly read them before adding any new template.
About the VBA code used behind each buttons
I will try to explain about the VBA code which I have used to create this tool in my next article. Meanwhile you can read my previous article where I had explained how to list all the folders and sub folders from a given path. In fact I am calling the same function on clicking on List existing Structure button. see you till my next article and don’t forget to download this workbook 🙂
FREE Download
Here is your FREE copy of the Folder Structure creator excel tool. Download this, use it and do not forget to provide me your thoughts on it by typing your comment here or sending en email or you can twit me You can also share it with your friends colleagues and most importantly your Boss 😀
This is wonderful! Thank you so much!
Thank you so much Adrian for your feedback 🙂
This is a fantastic tool, Vishwamitra!
I made one change to your tool for my personal use by adding:
Application.CutCopyMode = False
right before the error hnadler in the loadTemplate sub.
This is such a useful tool, and extremely well thought-out.
Thank you for sharing!
Vishwamitra Mishra, this tool is great and i thank you so much.
I have one question though: is there any easy way for me to format my folders from an existing database query resultset? the results come out as a long list of full paths:
c:\temp\folder1\
c:\temp\folder1\ABC
c:\temp\folder1\DEF
c:\temp\folder2\abc
c:\temp\folder2\def
c:\temp\folder2\ghi
is there any easy way to format these lines to suit your tool template structure?
I can use text to cells but then i’m still left with all of the parent folders and there are thousands in the result set…
some clues?
I am getting an “Out of stack space” error.
It validated my structure prior to the error…
So it stops at about 107 folder
It works! You should make a youtube explanation dude. I was watching several youtube before i found your link this on some forums. This is wonderful and easy. Thank you!
It worked perectly! Many thanks 🙂
Great tool, thank you for sharing. Saved a lot of time. 🙂
Its good . But if my rootfolder is common and only sub folder is differant then it shows error
Hi, Hope you can help me, In my case, it stops after creating two folder structure. The error I get is ** Error Occured at: \\\ Lease. can you help, please?
** Error Description: Path not found
Brilliant, thank you so much Vishwamitra. Over an hour of research and trying to get to grips with VBA which I’ve never used before – then found your page and after 10 minutes of making my file fit your validation rules, 5 seconds later and 150 folders are created!
So wonderful….
Thank you so much for this tool! I had a large deep folder structure to create, found a limit of the macro at ~ record 250ish so had to create 2 folders and put the 400+ folders together afterwards. Brilliant work and thanks for sharing this. Much appreciated.
Thanks Ian, you can share it with the world, it might help others too 🙂