OfficeUser
Well-known Member
- Joined
- Feb 4, 2010
- Messages
- 544
- Office Version
- 365
- 2016
- Platform
- Windows
Hi, I am using this macro to create a folder, and then two predetermined folders within:
The issue is that it will always create folder using cell value in Column B but it will always error out eventually on this line:
Not sure where to go from here, works fine, then gets the hiccups. Any resources I should look at?
VBA Code:
Sub MakeFolders()
Dim xdir As String
Dim fso
Dim lstrow As Long
Dim i As Long
Set fso = CreateObject("Scripting.FileSystemObject")
lstrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "B").End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To 150 '<-- reads list from B2
'change the path on the next line where you want to create the folders
xdir = "C:\Prontoforms\" & Range("B" & i).Value
If Not fso.FolderExists(xdir) Then
fso.CreateFolder (xdir)
MkDir (xdir) & "\Weekdays"
MkDir (xdir) & "\Weekends"
End If
Next
Application.ScreenUpdating = True
End Sub
The issue is that it will always create folder using cell value in Column B but it will always error out eventually on this line:
Excel Formula:
MkDir (xdir) & "\Weekdays"
Not sure where to go from here, works fine, then gets the hiccups. Any resources I should look at?