Sub CheckDirectory()
If Dir("C:\desktop\example\folder\bob\") <> "" Then
MsgBox "This folder is already here"
Else
MsgBox "No, path does not exist."
End If
End Sub
source: Excel Checking if a directory exists
Code:Sub CheckDirectory() If Dir("C:\desktop\example\folder\bob\") <> "" Then MsgBox "This folder is already here" Else MsgBox "No, path does not exist." End If End Sub
Make sure you have the trailing backslash.
Sub CheckDirectory()
If Dir("C:\desktop\example\folder\bob\", vbDirectory) <> "" Then
MsgBox "This folder is already here"
Else
MsgBox "No, path does not exist."
End If
End Sub
You need to use the 2nd argument of Dir.
Code:Sub CheckDirectory() If Dir("C:\desktop\example\folder\bob\", vbDirectory) <> "" Then MsgBox "This folder is already here" Else MsgBox "No, path does not exist." End If End Sub