Macro to Create Folders and Subfolders

slparadise

New Member
Joined
Jan 30, 2015
Messages
16
I have to create folders weekly that all contain the same subfolders. I know it's possible to create a macro to do this but do not know how. The data that I would be using looks like this...

FOLDERSUBFOLDERSUBFOLDER
3978-93 CG2EngineeringTemplates
3972-97 CG2EngineeringTemplates
3624-114 CG2EngineeringTemplates

When completed, the folder would be 3978-93\Engineering\Templates

What is the easiest or simplest way to do this? Any and all help is greatly appreciated.

Thanks!!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
Rich (BB code):
Sub slparadise()
    Dim Cl As Range
    Dim Pth As String
    
    Pth = "C:\MrExcel\"
    For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
        MkDir Pth & Cl.Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value & "\" & Cl.Offset(, 2).Value
    Next Cl
End Sub
This assumes that none of the folders exist.
Change value in red to suit
 
Upvote 0
How about
Rich (BB code):
Sub slparadise()
    Dim Cl As Range
    Dim Pth As String
   
    Pth = "C:\MrExcel\"
    For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
        MkDir Pth & Cl.Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value & "\" & Cl.Offset(, 2).Value
    Next Cl
End Sub
This assumes that none of the folders exist.
Change value in red to suit

Perfect!!!

Thanks!!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
How about
Rich (BB code):
Sub slparadise()
    Dim Cl As Range
    Dim Pth As String
   
    Pth = "C:\MrExcel\"
    For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
        MkDir Pth & Cl.Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value & "\" & Cl.Offset(, 2).Value
    Next Cl
End Sub
This assumes that none of the folders exist.
Change value in red to suit
I have to create folders weekly that all contain the same subfolders. I know it's possible to create a macro to do this but do not know how. The data that I would be using looks like this...

FOLDERSUBFOLDERSUBFOLDER
3978-93 CG2EngineeringTemplates
3972-97 CG2EngineeringTemplates
3624-114 CG2EngineeringTemplates

When completed, the folder would be 3978-93\Engineering\Templates

What is the easiest or simplest way to do this? Any and all help is greatly appreciated.

Thanks!!
How about
Rich (BB code):
Sub slparadise()
    Dim Cl As Range
    Dim Pth As String
   
    Pth = "C:\MrExcel\"
    For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
        MkDir Pth & Cl.Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value
        MkDir Pth & Cl.Value & "\" & Cl.Offset(, 1).Value & "\" & Cl.Offset(, 2).Value
    Next Cl
End Sub
This assumes that none of the folders exist.
Change value in red to suit
FOLDERSUBFOLDER
test1test1-1
test1-2
test1-3
test1-4

Can I have 4 sub-folders in 1 folder?
 
Upvote 0
Hi & welcome to MrExcel.
As this is a significantly different question from the op, you need to start a new thread for your question. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top