In VBA, you can use MkDir function to create folders in your system or shared drive. To make your work simple, we bring a free Excel VBA tool to create folders. To use this tool, enter Base folder path where you want to create folders and the name of the folder. Click on ‘Create Folders’ and done, folders will be created in matter of seconds
'This function reads data from Excel sheet
'and create folders in the system or shared drive
Sub CreateFolders()
'Variable declaration
Dim lCounter As Long
Dim strFolderPath As String
'Clear Status column
Sheet1.Range("E4:E1000").ClearContents
Sheet1.Range("E4:E1000").Font.Color = vbBlack
Sheet1.Range("E4:E1000").Interior.Color = vbWhite
'Loop through all the records in sheet1
For lCounter = 4 To Sheet1.Range("C" & Sheet1.Rows.Count).End(xlUp).Row
'Validation - if column C or D has no value go to next record
If Sheet1.Range("C" & lCounter).Value <> "" And Sheet1.Range("D" & lCounter).Value <> "" Then
strFolderPath = Sheet1.Range("C" & lCounter).Value
'If the path is ending with slash then remove
If InStr(1, Right(strFolderPath, 1), "/") > 0 Or InStr(1, Right(strFolderPath, 1), "\") > 0 Then
strFolderPath = Left(strFolderPath, Len(strFolderPath) - 1)
End If
'Check if the base folder path is valid
If Dir(strFolderPath, vbDirectory) <> "" Then
'Check if new folder already exist in the base folder
If Dir(strFolderPath & "\" & Sheet1.Range("D" & lCounter).Value, vbDirectory) = "" Then
'Create new folder
MkDir (strFolderPath & "\" & Sheet1.Range("D" & lCounter).Value)
'Update the status
Sheet1.Range("E" & lCounter).Value = "Folder Created"
Sheet1.Range("E" & lCounter).Interior.Color = vbGreen
Else
Sheet1.Range("E" & lCounter).Value = "Folder Already Exist"
Sheet1.Range("E" & lCounter).Font.Color = vbRed
End If
Else
Sheet1.Range("E" & lCounter).Value = "Invalid Base Folder Path"
Sheet1.Range("E" & lCounter).Font.Color = vbRed
End If
Else
Sheet1.Range("E" & lCounter).Value = "Incomplete Details"
Sheet1.Range("E" & lCounter).Font.Color = vbRed
End If
Next
MsgBox "Done", vbInformation
End Sub
4. Click on ‘Create Folders’ shape
5. Done, your folders will be created and Status column will be updated as ‘Folder Created’
Note: You may get following Status comments as well
(i) Folder Already Exist – If the folder already available at destination
(ii) Invalid Base Folder Path – If the Base Folder Path is invalid
(iii) Incomplete Details – If Base Folder Path or New Folder Name are left blank
6. To clear the data, click on ‘Clear Data’
We are offering Excel VBA Course for Beginners to Experts at discounted prices. The courses includes On Demand Videos, Practice Assignments, Q&A Support from our Experts. Also after successfully completion of the certification, will share the success with Certificate of Completion
This course is going to help you to excel your skills in Excel VBA with our real time case studies.
Lets get connected and start learning now. Click here to Enroll.
Here is another best rated Excel Charts and Graph Course from ExcelSirJi. This courses also includes On Demand Videos, Practice Assignments, Q&A Support from our Experts.
This Course will enable you to become Excel Data Visualization Expert as it consists many charts preparation method which you will not find over the internet.
So Enroll now to become expert in Excel Data Visualization. Click here to Enroll.
Hope you are enjoying learning Excel with us, if you want any support related to this article, please do comment else you can ask questions in Excel Community
Table of Content How does testing help? How should I test my tool or application? How does Dummy Data Generator tool helps in testing? How do I use this tool? From many years I have…
Working with huge data is always exciting and challenging. From 2007 version onward, Excel is supporting more than a million rows in each worksheet. One of the common problems with huge data is “Duplicates” and the bigger problem is to identify and remove these duplicates. In this article, we will be sharing 4 ways to delete duplicate records from your data.
Excel Files and Sheets Consolidator is an MS Excel based data consolidation tool which can be used to consolidate data from multiple Excel Files or Excel Sheets. The tool supports multiple configurations such as Sheet Name, Sheet Index, Header Row and Non-Blank column to help consolidating accurate data.
Here is one more wonderful free tool from ExcelSirJi.com which makes your life easy. Time & Motion Tracker helps you to track Start and End time of any type of transaction or activity. The good thing is, it is VBA based tool which helps you to protect from manual manipulation in the data by the user. It is also easy to use, just click on Start (shortcut: Ctrl+Shift+A) or Stop (Ctrl+Shft+S) buttons to record the time
Free File Renamer Tool – Quickly Rename files batch using Excel VBA Here is another help code and tool for programmers to rename files. You can use this tool for renaming all files available in…
Time and Motion Tracker is an MS Excel based tool which helps you to track Start and End time of any type of transaction or activity. The tool is developed using VBA coding which helps you to protect manual manipulation in the data by the user. It is also easy to use, just click on Start (shortcut: Ctrl+W) or Stop (Ctrl+E) buttons to record the time stamp. This is professional version of our famous Time & Motion Tracker. This version includes features such as Hold Timer, Consolidation, Utilization Analysis, Dashboards etc.
Nice Article….Keep sharing such articles. It adds worth to our knowledge 🙂
It works well.
Thank you for the post
Thank you for visiting our website 🙂