Hi
This is working for me with in G4 "C:\Data" (The Data folder already exist)
and in I3 "Testfolder"
Sub MakeDirectory()
Dim project_dir As String
Dim Project_spec As String
Dim Project_path As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
project_dir = Worksheets("Road Editor").Range("G4")
Project_spec = Worksheets("Road Editor").Range("I3")
Project_path = project_dir & "\" & Project_spec
If Not fs.FolderExists(Project_path) Then
fs.CreateFolder Project_path
Else
' do nothing
End If
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"mathew" wrote in message ...
I need to check to see if a directory exists and if it does not then create it. I can do this when I specify the directory in the
last two lines of the
VB sub-routine, however, I need to get the path statement from 2 different user input cells on the worksheet.
Here is what I have. Can you please help!
Dim project_dir As String
Dim Project_spec As String
Dim Project_path As String
project_dir = Worksheets("Road Editor").Range("G4")
Project_spec = Worksheets("Road Editor").Range("I3")
Project_path = project_dir & "\" & Project_spec
On Error Resume Next
ChDir "Project_path"
If Err < 0 Then MkDir "Project_path"