Consulting

Results 1 to 3 of 3

Thread: MkDir and "Path Not Found" Run-time error 76

  1. #1

    MkDir and "Path Not Found" Run-time error 76

    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.

    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
    Last edited by Aussiebear; 09-28-2022 at 12:14 PM. Reason: Added code tags to supplied code

  2. #2
    Disregard. Error caused by an errant illegal character in filename.

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    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
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •