Home>Blogs>VBA>Create Multiple Folders from Excel Range
Create Multiple Folder
VBA

Create Multiple Folders from Excel Range

In the previous article you have learnt how to check the whether a folder exist or not. In this article you will learn we can create multiple folders on one click using excel range.

Create Multiple Folder

 

Below the VBA code to create multiple folder from excel sheet

Option Explicit

Sub Create_Multiple_Folder()

Dim sh As Worksheet

Set sh = ThisWorkbook.Sheets("Sheet1")

Dim sub_folder_path As String

Dim i As Integer

For i = 4 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row

        sub_folder_path = sh.Range("C1").Value & Application.PathSeparator & sh.Range("A" & i).Value

       If Dir(sub_folder_path, vbDirectory) = "" Then

   

        MkDir (sub_folder_path)

        sh.Range("B" & i).Value = "Folder Created"

    Else

        sh.Range("B" & i).Value = "Folder already available"

    End If

Next i

End Sub

 

Click here to download this Excel workbook for practice.

 

Watch the step by step video tutorial:

PK
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com