Hi, I have a list in excel, image attached, I am trying to create a folder structure using VBA that will nest the sub folders with the numbering as shown. I think I have seen this before but cannot for the life of me find where.
I have been using this code and it works great but it does not nest the folders. Once all the folders are created I have to manually move them. Can anyone help me solve this?
Many thanks in advance.
Fen
Sub CreateFolderStructure()
Dim objRow As Range, objCell As Range, strFolders As String
For Each objRow In ActiveSheet.UsedRange.Rows
strFolders = "C:\Folder Name Here"
For Each objCell In objRow.Cells
strFolders = strFolders & "\" & objCell
Next
Shell ("cmd /c md " & Chr(34) & strFolders & Chr(34))
Next
End Sub
I have been using this code and it works great but it does not nest the folders. Once all the folders are created I have to manually move them. Can anyone help me solve this?
Many thanks in advance.
Fen
Sub CreateFolderStructure()
Dim objRow As Range, objCell As Range, strFolders As String
For Each objRow In ActiveSheet.UsedRange.Rows
strFolders = "C:\Folder Name Here"
For Each objCell In objRow.Cells
strFolders = strFolders & "\" & objCell
Next
Shell ("cmd /c md " & Chr(34) & strFolders & Chr(34))
Next
End Sub