Does folder exist problem

G

Guest

My Code below is attempting to check if a folder exists and if so exit the
sub. Can anyone point me in the right direction

mypath = "e:\Temp\" & Actuals

If Dir(mypath) <> "" Then
MkDir mypath
Else
MsgBox "Folder already Exists"
Exit Sub
End If

For i = lb To ub
mypath = "e:\Temp\" & Actuals & Arr1(i)
If Dir(mypath) = "" Then
MkDir mypath
End If
Next i
 
T

Tom Ogilvy

If Dir(mypath) = "" Then
MkDir mypath
Else
MsgBox "Folder already Exists"
Exit Sub
End If
 
G

Guest

Thx Tom,

I have one more question, how best to trap the error generated when the
directory exists and the macro is attempting to overwrite it. How should I
capture that error and process it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

on error help 4
Open CSV File 4
Copy item from Outlook to folder via Excel 12
Detect file. 2
Type Mismatch 1
Rename rather than overwrite existing file 4
NEED HELP!!!! 1
Folder Button 2

Top