I have a list of folder locations in column A that define the directory hierarchy I am trying to create (e.g. "C:\topFolder\nextFolder\lastFolder\). The code runs with no errors, but no folders are created. What am I doing wrong here?
Sub newDestination()
Dim Path As Variant
Dim folderLevel As Variant
For Each Path In Sheet11.Range("A:A")
For Each folderLevel In Split(Path.Value, "\")
folderLevel = folderLevel & "\"
If Len(Dir(folderLevel, vbDirectory)) = 0 Then
MkDir folderLevel
End If
Next folderLevel
Next Path
End Sub
Pathis an Excel VBA built-in method, did you not get any error for thePathvariable declaration?Pathis built in property for few objects but not a built in method in Excel-VBA. Nonetheless not a very good choice as variable name.