I have a macro to create folders which are named in column B.
This works great but if one of the parent folders does not exist or the folder already exists, then an error occurs and the procedure stops.
How can I make it so the error does appear to inform the user, but then the procedure moves on to the next folder?
Here's the code I have at the moment.
Thanks
This works great but if one of the parent folders does not exist or the folder already exists, then an error occurs and the procedure stops.
How can I make it so the error does appear to inform the user, but then the procedure moves on to the next folder?
Here's the code I have at the moment.
Code:
Sub MakeFolders()
On Error GoTo ErrHandler
Dim NewStarters As Range, FolderName As Object
LR = Range("A" & Rows.Count).End(xlUp).Row
Set NewStarters = Range("B2:B" & LR)
For Each FolderName In NewStarters
If IsEmpty(FolderName) Then
Exit Sub
End If
cFolderName = FolderName.Value
MkDir cFolderName
Next
Exit Sub
ErrHandler:
MsgBox Err.Number & " - " & Err.Description & vbNewLine & _
cFolderName
End Sub
Thanks