hkydad
Board Regular
- Joined
- May 16, 2013
- Messages
- 66
- Office Version
- 365
- Platform
- Windows
Hi...
I have a list of folders on the network but I need to add a subfolder to them. Each main folder will be getting the same sub-folder. Below is the code I am currently using to create the main folders. How do I create the same sub folder in each of these folders. Thank you in advance for your assistance.
Sub CreateFolders()
Dim xdir As String
Dim fso
Dim fsoSub
Dim lstrow As Long
Dim i As Long
Dim xdirsubfolder As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoSub = CreateObject("Scripting.FileSystemObject")
lstrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = True
For i = 1 To lstrow
xdir = "J:\_Dvision\Group\Tim\2024\" & Range("A" & i).Value
xdirsubfolder = "J:\_Division\Group\Tim\2024\" & Range("A" & i).Value & "\" & Range("A" & i).Offset(0, 3)
If Not fso.FolderExists(xdir) Then
fso.CreateFolder (xdir)
End If
If Not fsoSub.FolderExists(xdirsubfolder) Then
fsoSub.CreateFolder (xdirsubfolder)
End If
Next
Application.ScreenUpdating = True
End Sub
I have a list of folders on the network but I need to add a subfolder to them. Each main folder will be getting the same sub-folder. Below is the code I am currently using to create the main folders. How do I create the same sub folder in each of these folders. Thank you in advance for your assistance.
Sub CreateFolders()
Dim xdir As String
Dim fso
Dim fsoSub
Dim lstrow As Long
Dim i As Long
Dim xdirsubfolder As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoSub = CreateObject("Scripting.FileSystemObject")
lstrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = True
For i = 1 To lstrow
xdir = "J:\_Dvision\Group\Tim\2024\" & Range("A" & i).Value
xdirsubfolder = "J:\_Division\Group\Tim\2024\" & Range("A" & i).Value & "\" & Range("A" & i).Offset(0, 3)
If Not fso.FolderExists(xdir) Then
fso.CreateFolder (xdir)
End If
If Not fsoSub.FolderExists(xdirsubfolder) Then
fsoSub.CreateFolder (xdirsubfolder)
End If
Next
Application.ScreenUpdating = True
End Sub