Hi,
1. How to modify the code below to prompt for the path (browse for directory/folder)
2. Not sure why when run code it create folder, but after it freeze saying not responding (I have to end task)
here is the code:
Code:
Attached screenshot of file.
1. How to modify the code below to prompt for the path (browse for directory/folder)
2. Not sure why when run code it create folder, but after it freeze saying not responding (I have to end task)
here is the code:
Code:
VBA Code:
he path (browse for directory/folder)
2. Not sure why when run code create folder but freeze said not responding (I have to end task)
here is the code:
Code:
Sub CreateFolders()
Dim aCustomers
Dim aArticles
Dim i
Dim j
Dim sPath
sPath = "H:\07 Jul 2024\AP_Accruals\"
With ThisWorkbook.Sheets(1)
aCustomers = .Range(.Range("A1"), .Range("A1").End(xlDown)).Value
aArticles = .Range("B1:B9").Value
End With
For i = LBound(aCustomers, 1) To UBound(aCustomers, 1)
For j = LBound(aArticles, 1) To UBound(aArticles, 1)
SmartCreateFolder sPath & "\" & aCustomers(i, 1) & "\" & aArticles(j, 1)
Next
Next
End Sub
Sub SmartCreateFolder(sFolder)
Static oFSO As Object
If oFSO Is Nothing Then Set oFSO = CreateObject("Scripting.FileSystemObject")
With oFSO
If Not .FolderExists(sFolder) Then
SmartCreateFolder .GetParentFolderName(sFolder)
.CreateFolder sFolder
End If
End With
End Sub
Attached screenshot of file.