I want to create a list of folders based on the entries in column A. I found this code online but always run into an error for line 52 saying "Bad file or name number."
I am new to excel VBA and don't know how to fix it. Can someone help me resolve this, or find another way to create folders from a column in Excel?
The debugger shows that this is the line with the error: If Len(Dir(ActiveWorkbook.Path & "" & Rng(r, c), vbDirectory)) = 0 Then
I've attached the file I'm trying to make folders with.
Please and thank you!
Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
Bookmarks