ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Generate document folders for Excel list. (https://www.excelbanter.com/excel-programming/353200-generate-document-folders-excel-list.html)

Jim15[_10_]

Generate document folders for Excel list.
 

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

--
Jim1
-----------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...fo&userid=2630
View this thread: http://www.excelforum.com/showthread.php?threadid=51194


ben

Generate document folders for Excel list.
 
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



--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Jim15" wrote:


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

Thanks,

Jim


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=511949



Jim15[_11_]

Generate document folders for Excel list.
 

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


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=511949


ben

Generate document folders for Excel list.
 
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

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"ben" wrote:

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



--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Jim15" wrote:


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

Thanks,

Jim


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=511949



ben

Generate document folders for Excel list.
 
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....

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"ben" wrote:

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

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"ben" wrote:

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



--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Jim15" wrote:


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

Thanks,

Jim


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=511949



Jim15[_15_]

Generate document folders for Excel list.
 

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

--
Jim1
-----------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...fo&userid=2630
View this thread: http://www.excelforum.com/showthread.php?threadid=51194


Jim15[_17_]

Generate document folders for Excel list.
 

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


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=511949



All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com