I found this post from earlier this year. I used it to create a folder and subfolder structure and it appeared to work well but was only able to go one subfolder level deep. In the below data set folders from Column B and folders for Column C were all created as subfolders of Column A. I want Column C to be a subfolder of Column B,
My format is :
to create a file structure in windows that looks like this:
I used this code:
I would like to modify the above code to meet my needs but I am pretty new to this type of coding.
Any help that could be provided would be great.
My format is :
Column A | Column B | Column C |
FOLDER 1 | folder 1.1 | folder 1.1.1 |
FOLDER 1 | folder 1.1 | folder 1.1.2 |
FOLDER 1 | folder 1.2 | folder 1.2.1 |
FOLDER 1 | folder 1.2 | folder 1.2.2 |
FOLDER 2 | folder 2.1 | folder 2.1.1 |
FOLDER 2 | folder 2.2 | folder 2.2.1 |
to create a file structure in windows that looks like this:
I used this code:
VBA Code:
Public Sub CreateFolderStructure2()
Dim baseFolder As String
Dim objRow As Range, c As Long
baseFolder = "C:\path\to\base folder\"
If Right(baseFolder, 1) <> "\" Then baseFolder = baseFolder & "\"
For Each objRow In Worksheets("Sheet2").UsedRange.Rows
For c = 2 To objRow.Cells.Count
Shell "cmd /c md " & Chr(34) & baseFolder & objRow.Cells(1, 1) & "\" & objRow.Cells(1, c) & Chr(34)
Next
Next
End Sub
I would like to modify the above code to meet my needs but I am pretty new to this type of coding.
Any help that could be provided would be great.
Last edited by a moderator: