Hi
I have below code for creating a folder in the same directory as the active workbook.
The folder name should be the content of the selected cells when I run the macro.
However, I get an error "Bad file name or number (Error 52)" on this code line when debugging:
Any idea, what the issue could be?
Here's the code I use:
I have below code for creating a folder in the same directory as the active workbook.
The folder name should be the content of the selected cells when I run the macro.
However, I get an error "Bad file name or number (Error 52)" on this code line when debugging:
VBA Code:
If Len(Dir(ThisWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
Any idea, what the issue could be?
Here's the code I use:
VBA Code:
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(ThisWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ThisWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub