Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create New Folder Using Code
I run a series of spreadsheets for daily reports every morning, what I would
love to have happen is the following when the first report runs it will create a folder in the main reports folder (which is called reports) the folder name needs to be the current date(format mmddyyyy) when the next report runs it needs to look and see if the folder for the current day exists and if so move on, otherwise create the folder (just in case I run a report early to check data) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create New Folder Using Code
Nigel,
Try something like this: Sub test() Dim strMainFolder As String Dim strFolder As String strMainFolder = "D:\REPORTS\" strFolder = Format(Now, "mmddyyyy") If Dir(strMainFolder & strFolder, vbDirectory) = "" Then MkDir strMainFolder & strFolder End If End Sub -- Hope that helps. Vergel Adriano "Nigel" wrote: I run a series of spreadsheets for daily reports every morning, what I would love to have happen is the following when the first report runs it will create a folder in the main reports folder (which is called reports) the folder name needs to be the current date(format mmddyyyy) when the next report runs it needs to look and see if the folder for the current day exists and if so move on, otherwise create the folder (just in case I run a report early to check data) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Create New Folder Using Code
On Error Resume Next MkDir "C:\Main Reports\" & Format(Date,"mmddyyyy") On Error goto 0 maybe better to do yyyymmdd for sorting purposes. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Nigel" wrote in message ... I run a series of spreadsheets for daily reports every morning, what I would love to have happen is the following when the first report runs it will create a folder in the main reports folder (which is called reports) the folder name needs to be the current date(format mmddyyyy) when the next report runs it needs to look and see if the folder for the current day exists and if so move on, otherwise create the folder (just in case I run a report early to check data) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save file in a new folder, but create folder only if folder doesn't already exist? | Excel Programming | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
Create Folder and Text File in folder | Excel Programming | |||
Create Folder / Copy Folder / Replace | Excel Programming | |||
Create Folder..... | Excel Programming |