PDA

View Full Version : [SOLVED:] MkDir and "Path Not Found" Run-time error 76



ChrisCione
09-28-2022, 08:16 AM
As the subject line reads, I am receiving an error when attempting to create multiple folders on a network drive from a list in Excel using the module below. I did this last week, and it worked perfectly (created over 3000 folders in a split second). Today I replicated the action, with a different list, to no avail. Disclaimer: I didn't create the module, nor would I even know how to do so. I found the instructions to do this on a blog at Create folders from a list in Excel (https://www.iltanet.org/blogs/amy-bowser-rollins1/2021/02/09/litigation-support-tool-tip-create-folders-from-a).

Clicking debug highlights this line: MkDir (ActiveWorkbook.Path & "" & Rng(r, c))

I tried placing the activeworkbook.path name in the module below and am receiving different errors. Any help is greatly appreciated.

Module:


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

ChrisCione
09-28-2022, 08:50 AM
Disregard. Error caused by an errant illegal character in filename.

Aussiebear
09-28-2022, 12:22 PM
You may want to change the line


Dim maxRows, maxCols, r, c as Integer
to

Dim maxRows as Integer, maxCols as integer, r as integer, c as Integer