Hello friends,
I am trying to create folders and subfolders from the cells by using VBA code.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]France[/TD]
[TD]Paris[/TD]
[TD]Nice[/TD]
[TD]Marseille[/TD]
[TD]Lyon[/TD]
[TD]Nantes[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]UK[/TD]
[TD]London[/TD]
[TD]Manchester[/TD]
[TD]Liverpool[/TD]
[TD]Oxford[/TD]
[TD]Preston[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Italy[/TD]
[TD]Milan[/TD]
[TD]Naples[/TD]
[TD]Rome[/TD]
[TD]Turin[/TD]
[TD]Genoa[/TD]
[/TR]
</tbody>[/TABLE]
Please find the code I tried to use below:
When I run the code, the following things created:
Instead of that, I want this thing to happen:
How can I do that? By the way, if you want to change the whole formula, please feel free to change. I will apply it for more than 250 cells.
I am trying to create folders and subfolders from the cells by using VBA code.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]France[/TD]
[TD]Paris[/TD]
[TD]Nice[/TD]
[TD]Marseille[/TD]
[TD]Lyon[/TD]
[TD]Nantes[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]UK[/TD]
[TD]London[/TD]
[TD]Manchester[/TD]
[TD]Liverpool[/TD]
[TD]Oxford[/TD]
[TD]Preston[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Italy[/TD]
[TD]Milan[/TD]
[TD]Naples[/TD]
[TD]Rome[/TD]
[TD]Turin[/TD]
[TD]Genoa[/TD]
[/TR]
</tbody>[/TABLE]
Please find the code I tried to use below:
Code:
Sub CreateFolderStructure() For Each objRow In UsedRange.Rows
strFolders = "C:\Users\USERID\Desktop\newnew"
For Each ObjCell In objRow.Cells
strFolders = strFolders & "\" & ObjCell
Next
Shell ("cmd /c md " & Chr(34) & strFolders & Chr(34))
Next
End Sub
When I run the code, the following things created:
- C:\Users\USERID\Desktop\newnew\France\Paris\Nice\Marseille\Lyon\Nantes
- C:\Users\USERID\Desktop\newnew\Italy\Milan\Naples\Rome\Turin\Genoa
- C:\Users\USERID\Desktop\newnew\UK\London\Manchester\Liverpool\Oxford\Preston
Instead of that, I want this thing to happen:
- C:\Users\USERID\Desktop\newnew\France\Paris
- C:\Users\USERID\Desktop\newnew\France\Nice
- C:\Users\USERID\Desktop\newnew\France\Marseille
- C:\Users\USERID\Desktop\newnew\France\Lyon
- C:\Users\USERID\Desktop\newnew\France\Nantes
- C:\Users\USERID\Desktop\newnew\Italy\Milan
- C:\Users\USERID\Desktop\newnew\Italy\Naples
- C:\Users\USERID\Desktop\newnew\Italy\Rome
- C:\Users\USERID\Desktop\newnew\Italy\Turin
- C:\Users\USERID\Desktop\newnew\Italy\Genoa
- C:\Users\USERID\Desktop\newnew\UK\London
- C:\Users\USERID\Desktop\newnew\UK\\Manchester
- C:\Users\USERID\Desktop\newnew\UK\\Liverpool
- C:\Users\USERID\Desktop\newnew\UK\\Oxford
- C:\Users\USERID\Desktop\newnew\UK\\Preston
How can I do that? By the way, if you want to change the whole formula, please feel free to change. I will apply it for more than 250 cells.