Create Folders based on Cell Value in Excel

1) Create or navigate to the root folder under which you want to create the folders from the list.

2) Open a new Excel file within this root folder.

3) Populate column 1 with the name of the folders, 1 in each row.

4) Once populated, select the data range.

5) Click on the Developer menu.

Note: The Developer tab isn’t displayed by default, but you can add it to the ribbon. On the File tab, go to Options > Customize Ribbon. Under Customize the Ribbon and under Main Tabs, select the Developer check box.

6) Click on Insert > Module.

Note: In newer Excel versions, click on Visual Basic > Insert > Module.

7) Copy and paste the below code.

Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir (ActiveWorkbook.Path & “\” & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & “\” & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Next c
End Sub

8) Click on Run.

9) Go and check the root folder and folders from the folder list in Excel has been created.

10) Enjoy!

Leave a Reply