Anne Troy
asked on
Error on make folder Excel VBA
If Len(Dir("Report " & Format(Date, "yyyymmdd"))) = 0 Then
MkDir "Report " & Format(Date, "yyyymmdd")
Else
MsgBox "You already ran today's reports and need to delete the folder before running them again."
Exit Sub
I just get a Path/File access error on the MkDir line of code instead of getting the message box.
I have tried moving the lines around, too. Anybody know what I'm doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It appears I needed BOTH.
Thanks so much!
Sub create()
If Len(Dir("Report " & Format(Date, "yyyymmdd"), vbDirectory)) = 0 Then
MkDir ThisWorkbook.Path & "\" & "Report " & Format(Date, "yyyymmdd")
Else
MsgBox "You already ran today's reports and need to delete the folder before running them again."
Exit Sub
End If
End Sub
Thanks so much!
Sub create()
If Len(Dir("Report " & Format(Date, "yyyymmdd"))) = 0 Then
MkDir "C:\Users\rvatta\Desktop\R
Else
MsgBox "You already ran today's reports and need to delete the folder before running them again."
Exit Sub
End If
End Sub