Check folder existance using cell reference

Hello, Can anyone tell me I get a 'type mismatch' error message with the second version below?
A specific folder reference, as in the first example, works just fine
Many thanks!
If Dir("C:\Backup5", vbDirectory) = "" Then
MkDir "C:\Backup5"
End If

Open in new window

If Dir(Range("S9").Value, vbDirectory) = "" Then
MkDir Range("S9").Value
End If

Open in new window

davidamAsked:
Who is Participating?
 
jppintoConnect With a Mentor Commented:
I've tested your code and works fine on my computer...

I've tested putting this:

C:\Test

on cell S9 and it worked fine. No errors presented!
0
 
jppintoCommented:
What do you have on cell S9?
0
 
davidamAuthor Commented:
C:\Backup5
0
 
jppintoCommented:
Are you sure you don't have spaces on your cell?
0
 
davidamAuthor Commented:
So I am actually taking the cell reference from the active workbook and not the workbook that holds the code.  I originally put a procedure directly into the workbook without making a module...now I put it in a module and it works fine.  I dunno.  I will just accept your solution because you made it clear toi me that it should work. Many thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.