Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I would like to create a folder using the values in a specific cell on
a worksheet. Let's say, for instance, that the value of A1 is: C: \Reports\2007-09-18 The 'Reports' directory MAY OR MAY NOT already have a '2007-09-18' folder. I would like the code to be conditional, in that it will create the folder if it does not exist, otherwise don't do anything. Any help is much appreciated. Thanks. Kevin |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One way:
Sub foo() Dim d As String d = Range("A1").Text If Dir(d, vbDirectory) < "" Then MsgBox d & " already exists", , "Error" Else MkDir d End If End Sub DoooWhat wrote: I would like to create a folder using the values in a specific cell on a worksheet. Let's say, for instance, that the value of A1 is: C: \Reports\2007-09-18 The 'Reports' directory MAY OR MAY NOT already have a '2007-09-18' folder. I would like the code to be conditional, in that it will create the folder if it does not exist, otherwise don't do anything. Any help is much appreciated. Thanks. Kevin |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks so much! That worked perfectly.
Kevin |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
JW's worked, so I didn't attempt the other solution. I appreciate
everybody's input. Kevin |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
Try this: Dim Fldr As Scripting.FileSystemObject Set Fldr = New Scripting.FileSystemObject If Fldr.FolderExists("C:\Reports\2007-09-18") Then Else Fldr.CreateFolder "C:\Reports\2007-09-18" End If make sure you have referred to MicroSoft Scripting Runtime from ToolsReferences Thanks, -- Farhad Hodjat "DoooWhat" wrote: I would like to create a folder using the values in a specific cell on a worksheet. Let's say, for instance, that the value of A1 is: C: \Reports\2007-09-18 The 'Reports' directory MAY OR MAY NOT already have a '2007-09-18' folder. I would like the code to be conditional, in that it will create the folder if it does not exist, otherwise don't do anything. Any help is much appreciated. Thanks. Kevin |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Just another option. If it exists, it will skip MkDir.
Sub Demo() Const d As String = "C:\Reports\2007-09-18\" On Error Resume Next MkDir d End Sub -- HTH :) Dana DeLouis "DoooWhat" wrote in message ups.com... I would like to create a folder using the values in a specific cell on a worksheet. Let's say, for instance, that the value of A1 is: C: \Reports\2007-09-18 The 'Reports' directory MAY OR MAY NOT already have a '2007-09-18' folder. I would like the code to be conditional, in that it will create the folder if it does not exist, otherwise don't do anything. Any help is much appreciated. Thanks. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to create a new folder according to the month | Excel Discussion (Misc queries) | |||
How to create a copy of a folder having five files in it, & rename | Excel Worksheet Functions | |||
create folder and save as | Excel Discussion (Misc queries) | |||
How to create the hyperlink from Excel doc. to the folder | Excel Discussion (Misc queries) | |||
How do I Create backup of excel file in other folder | Excel Discussion (Misc queries) |