Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create New Folder in a drive

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Dear All,

I am currently using the coding below to create new folders in a drive, a couple of problems I have are that if the folders exists the command wont create a folder, and also I have to update my SS with all new folder locations, I was wondering if there is a way to search a drive and for each instance of the previous month(September) it creates a folder called October next to it, for example.

h:\reports\September (create a folder here as september found)
H:\new reports\September(create a folder here as september found)
I currently have approx 80 folders to create and also remember to add to the ss so the current coding will create new folders. Is there a way of adapting the current coding to do this for me.

Current Coding

Sub Create_Folders()

Sheets("copy_Folder").Select
For R = 2 To 64 'data in rows 2-61
On Error Resume Next

Application.ScreenUpdating = False

folderloc = Cells(R, 1)
MonthNam = Cells(R, 2)
completeadd = (folderloc & MonthNam)
MkDir (completeadd)

Next R
MsgBox "All New Folders Created", vbInformation

Any help will be greatly appreciated.

Rob.


 
Rob,

Before creating the directory, use the Dir function to see if the directory exists
if so
update SS accordingly
else
MkDir
update SS accordingly
end if
;P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top