Generate document folders for Excel list.

  • Thread starter Thread starter Jim15
  • Start date Start date
J

Jim15

I have a need to generate separate folders in a directory using a colum
list in Excel. I want the program to take an Excel file wit
descriptions in each row (column A only) and generate separate folder
with the descriptions being the folder name. Would generate anywher
from 50 - 100 (or more) directory folders.

Thanks,

Ji
 
sub createfolders()
dim cou as integer,Dim FolderStr as string, FileSys
for cou = 1 to activesheet.usedrange.rows.count
forlderstr = activesheet.cells(cou,1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder "C:\"+folderstr
next
end sub

replace "C:\" with appropriate drive and subfolder where they will be placed
also, certain characters are illegal in folder names, and if the folder
already exists the createfolder method will fail.
Xl2003
 
In addition, I would like the program to label the folders starting from
row 1 and label them like 1_foldername, 2_foldername, 3_foldername,
4_foldername, etc.

The row names are in importance of information and I do not want them
arranged alphabetically.

Thanks,

Jim
 
use this instead then




sub createfolders()
dim cou as integer,Dim FolderStr as string, FileSys
for cou = 1 to activesheet.usedrange.rows.count
forlderstr = Format(Trim(Str(cou)), "00#") + "_" + activesheet.cells(cou,1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder "C:\"+folderstr
next
end sub


this will organize numerically and not by text
 
oops
this line
forlderstr = Format(Trim(Str(cou)), "00#") + "_" + activesheet.cells(cou,1)
should read
folderstr = Format(Trim(Str(cou)), "00#") + "_" + activesheet.cells(cou,1)
my bad, typo....
 
I am getting a syntax and compile error on the dim cou .... line. An
suggestions?

Thanks,

Jim

Sub createfolders()
'
'
dim cou as integer,Dim FolderStr as string, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_"
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Su
 
Thanks for the assistance. I am know getting an error on the line right
before the "Next" line. I am trying to create a folder called
C:\RESERVES on the hard drive with subfolders as listed in column A.

Sub createfolders()
'
' CreateFolders Macro
' Macro recorded 3/22/2006 by JBW
'
Dim cou As Integer, FolderStr As String, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Sub
 
Back
Top