Create Folders in Directory with Excel VBA?

Hi,

Is there a way to create folders with a specfic names, and have them
saved in a directory.  I have an excel file with 250 records with my
desired folder names.

I want to avoid having to through the process of selecting <File | New
| Folder> then naming the folder -- 250 times!

I imagine there's an easier way with VBA... please help!

Thanks

0
jrew23 (22)
6/15/2005 10:11:41 PM
excel 39879 articles. 2 followers. Follow

4 Replies
402 Views

Similar Articles

[PageSpeed] 55

It can be done something like this. Attatch code to a command button on the 
sheet.
Alter code  to suit your reqirements. Test on a dummy workbook first until 
you get it to work the way you want.

Please note that there are practical limits in windows in the number of 
subfolders that can be created in a folder etc.
You may run into problems with 250 in the same subfolder.


Private Sub CommandButton1_Click()

' assuming names are all legal characters.
On Error Resume Next
ChDrive "c" ' make sure you are on the drive you want be
ChDir "\"  ' make sure you are in the root dir
ChDir "demo"  ' change to the dir you want the folders created in

For i = 10 To 15 ' loop thru the cells with the names (assumes col E rows 10 
to 15)
MkDir Worksheets("sheet1").Cells(i, "e")
Next i

End Sub


HTH

Ken 


0
KenMacksey (98)
6/15/2005 11:07:33 PM
Take a look at mkdir in VBA's help.

Jrew23 wrote:
> 
> Hi,
> 
> Is there a way to create folders with a specfic names, and have them
> saved in a directory.  I have an excel file with 250 records with my
> desired folder names.
> 
> I want to avoid having to through the process of selecting <File | New
> | Folder> then naming the folder -- 250 times!
> 
> I imagine there's an easier way with VBA... please help!
> 
> Thanks

-- 

Dave Peterson
0
ec357201 (5290)
6/15/2005 11:08:34 PM
you should use Access; it works better; and it wont crap out at 64k
rows lol

0
aaron.kempf (776)
6/16/2005 12:14:46 AM
aaron.kempf@gmail.com wrote...
>you should use Access; it works better; and it wont crap out at 64k
>rows lol

Another example of the wrong tool for the task.

Making directories is an OS task for which neither Excel nor Access
provide built-in support. Both would need to use VBA.

Better by far would be creating the folder listing as a text file, then
using the GnuWin32 xargs command to process each line in the file as
the name of a folder to create.

USE THE BEST TOOL FOR THE TASK.

But let's assume the OP doesn't have xargs or any other scripting
language other than Excel. What's needed in Excel/VBA?

Sub md()
  Dim c As Range
  If Not TypeOf Selection Is Range Then Exit Sub
  For Each c In Selection
    Mkdir c.Value
  Next c
End Sub

which allows the user to select the folders to create by selecting
cells in a worksheet.

Access can handle more than 65535 records, but no sane person would use
either Excel or Access to create that many or more folders. Oops, that
could imply you might!

Anyway, oh great sage, how to do this in Access? Details, not more BS!

0
hrlngrv (1990)
6/16/2005 2:40:31 AM
Reply:

Similar Artilces:

making boxplot in excel 2007
Hey. Got a problem on making a boxplot in excel 2007. I used to make excel 2003 to make the boxplot, but now I have the 2007 edition. I learned from my teacher that I need to use the "High-Low-lines" and the "Up/down-bars" to make the boxplot. The problem is that when I made the "Up/down-bars" it will cover the data-points so I can't see median ect. Is there anyway to change the order of the chart-figures like to show the data-point at the top, the up/down-bars in the middle and the high-low-lines at the bottom just like when u change the order of several...

Import multiple photos into excel
I am trying to create a photo sheet that will allow me to import all photos in a directory into an excel spreadsheet. I want it to: Import all images in a directory. (even if I have to choose to open the folder and then select all) Place each photo into a separate box Auto-format all the photos to the same size where (2) images fit on each printed page. Have a space for a text description to the right of each photo. Auto-number each row/photo if possible (so it changes all the numbers if I delete a row) Place a header with a logo on each printed page. Insert a merge field in t...

Microsoft Excel has encountered a problem and needs to close
When I close the excel application window return the following error message: Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience. AppName: excel.exe AppVer: 10.0.6713.0 ModName: msvcrt.dll ModVer: 7.0.2600.3085 Offset: 00037efb I tried to lookup this error in the Knowlwdge Base from Microsoft but I cann't found how to fix the problem. Thanks in advance for any help. Maybe try running Detect and Repair. Goto the Help menu, select Detect and Repair -- Biff Microsoft Excel MVP "Sergio" <Sergio@discussions.microsoft.co...

when trying to email from excel there is no send button what is w.
I have microsoft outlook and office express my email is yahoo. i tried to send straight from excel and an email box comes up but no send i don't think my emal is connected can anyone help From Excel click 'File', then 'Send To', then choose 'Mail Recipien (as Attachment)' This should open a new mail with the file attached. Enter th recipients email address and send -------- Message sent via www.excelforums.com kido123w the following is what I use in our office to fix the same problem. copy and paste the following into notepad [HKEY_CURRENT_USER\Software\te...

one note opens all folders
For a couple of weeks now onenote opens all the folders on my computer as the default. I just want it to do the 'explore' option as normal. It only opens folders in onenote, not the documents or other file types contained within them, they open as normal. I've tried to reset the defaults for folders through control panel with no success. I've read you can delete a key in the registry to fix this but I'm not sure about doing this. My computer runs vista and onenote 2007. I'm not sure what's caused the problem, my computer's aniti-virus Kaspe...

Excel fails to update call to user-written function.
I run Excel 2002 under <cringe> Win 2000. Although recalc is set to automatic, Excel often fails to calc cells that call functions I wrote in VBA--i.e. whose formula is =MyFunc(). I have a workbook with hundreds of cells with formula "=MyFunc (param)", where param is the address of another cell. MyFunc() returns some text plus the target cell's address. So if, say, I insert a row in the sheet, all cells calling MyFunc() below the row I inserted should update. But few or often even none do. (Except if on the cell I press F2-Edit and return, which of course works.) My only...

Phantom mail folder
I tried Outlook Connector but decided against using it. During the setup, for some reason, it setup two new mail folders for my MSN address but one of them didn't work. Clicking it gets a prompt "the set of folders couldn't be opened" along with a "show help" prompt. This is what the help screen shows: This error usually appears if the OST or PST file you are using is: Unavailable Protected with file permissions On a share on a server and the network is down Corrupt To correct this problem, store the OST or PST f...

Public Folders from 2000 to 2003
Hi How would I go about moving public folders from a exchange 2000 > 2003 server? Is there a an article or similar regarding the process? Thanks Use the pfmigrate.wsf script on Exchange Server 2003 CD. http://support.microsoft.com/default.aspx?scid=kb;en-us;822895 -- Bharat Suneja MCSE, MCT ----------------------------------- "Bladerunner" <Bladerunner@discussions.microsoft.com> wrote in message news:643C5103-795D-48CC-BA13-1313E8BB4700@microsoft.com... > Hi > > How would I go about moving public folders from a exchange 2000 > 2003 > server? Is there a...

creating sharepoint lists
Sharepoint lists seem to require a single line of text column, as a minimum. If I don't create one, the column "title" will be added automatically. Is there anyway around this? The list I'm trying to create requires a multi-line text column, two look-up columns, and a multi-choice column. A list is a content type, which will inherit the base elements of the parent content type, which happens to be Item, which contains the Title column. You can add any column types you wish. you will simply still have the title in addition to any column you create or add. you can...

Server Busy message during printing from Excel after Off. 2003 SP2
Hello. I have an application written in MFC which reports some information to MS Excel. A "Server busy" dialog is displayed within processing after printing from Excel. After creating a report I'm calling: - Minimize my report application - Displaying Excel window - Print preview (user can print document) - Closing a Workbook (without any prompt to save) - Quit Excel application - Restore my report application After printing from Excel, the "Server busy" dialog box is displayed (no close and quit behavior is processed, even the Retry button is pressed)...

Re: Download folder in Vista HP 64 ?
"FDLeyda" <fdleyda@no_reply.com> wrote in message news:#2vrPR87KHA.2248@TK2MSFTNGP05.phx.gbl... >>> Maybe so. I don't know. But if that's correct, and it were my machine, >>> the first thing I would do would be to get rid of that (and anything >>> else that HP puts on). >> >> Concurred. I have 3 Dells and my daughter has an HP. First thing I did >> with all of them was to burn their version of a restore disk, then >> installed clean versions of Vista/7. All f them take no time to boot up >> and run ...

Columns in Excel
I have the following problem I need help with: Column 1 Column2 Column3 Column4 017290 117110 246781 017450 117118 246790 017451 117119 317891 116127 246761 317990 116128 246771 341772 116129 246780 358381 Say I want to insert a new number into "Column 2." The number 119000. How can I do this and make all the information move automatically to look like the following: Column 1 Column2 Column3 Column4 017290 117110 246780 358381 017450 ...

How does excel determine the range of a list?
Hey, I'm working with worksheets that have more than one list on them. I need to define the range of the list and I only know one cell of the list. How does excel determine the range of a list if you select one cell and set the autofilter or sort data? I'm doing this in VBA and was trying to find something like FilterDatabase to define the range but these list are not filtered or named. Hi If first cell is A1 and your list your list has no empty rows in the column before end of the list, you can use this: Set FilterRange=range("A1",Range("A1").End(xl...

How do I insert a message when a user opens my Excel workbook?
Hi KP, Try: something like: '================>> Private Sub Workbook_Open() MsgBox "Hello from KP!" End Sub '================>> This is workbook event code and should be pasted into the workbook's ThisWorkbook module *not* a standard module or a sheet module): **************************************************** Right-click the Excel icon on the worksheet (or the icon to the left of the File menu if your workbook is maximised) Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. If you are not familiar with mac...

CHANGE WHOLE EXCEL worksheet TO UPPERCASE LETTERS?
My boss wants me to change a whole excel document to uppercase letters. It has like 43,000 records. How do I do that? He says it's possible, but I've never seen it done. I'm Using Excell 2003. Your boss must be thinking of using a macro. Take a look here: http://www.mvps.org/dmcritchie/excel/proper.htm#upper In article <608169EE-E690-4B26-AFD2-2FE9ECEBE856@microsoft.com>, "mineralgirl" <mineralgirl@discussions.microsoft.com> wrote: > My boss wants me to change a whole excel document to uppercase letters. It > has like 43,000 records. How do...

Excel add-ins - "xla could not be found"
Recently I started using Excel add-ins (xla files) -- which I have found very handy. For example, I have an add-in that can add a contents page to my workbook, or the list the file contents of a folder, etc. The trouble is, if someone, who doesn't have same xla files on their computer opens my spreadsheet they get a message: "...xla could not be found. Check the spelling of the file name" etc. After that they can open file fine. And apart from the messages, there seems to be no other problem; but I don't see why it is necessary for this message to occur. The add-ins helped me...

Excel #21
I have a spreadsheet comprised of entries like this : 726016004084 ALV BAG DANDELION United Natural Foods Inc. 726016004084 ALV BAG DANDELION Select Nutrition Dist. 726016004084 ALV BAG DANDELION Threshold 726016004190 ALV BAG ECH-GOLD-SEL United Natural Foods Inc. 726016004213 ALV BAG ELDERBERRY Threshold 726016004213 ALV BAG ELDERBERRY Select Nutrition Dist. What I want to do is reduce the list so 726016004084 ALV BAG DANDELION United Natural Foods Inc., Select Nutrition Dist., Threshold 726016004190 ALV BAG ECH-...

Excel Reports & BP 4.0
Loading any of the Excel Reports published to the BusinessPortal Reports Library gets Login Failed for user ". The user is not associated with a trusted SQL Server Connection If I use a SQL Server Authentication name it works. I want to use the Windows Authentication to eliminate the extra logon prompt. Can anyone tell me what am I missing? ***************** Microsoft Office Excel Login Failed for user ". The user is not associated with a trusted SQL Server Connection Microsoft SQL Server Login Connection Failed: SQLState: '42000' ...

IMAP email and folders
Hi I have an exchange 2000 Server providing all the email services for my domain. I wish to give my users IMAP access. I have configured the accounts so that the users can log on using their IMAP clients, however none of my users can download anything other than email headers, and none of my users folders (other than Inbox) are retreived. This behaviour is the same inside the LAN and on a WAN. Any ideas? ...

Word document embedded in Excel 2003 won't wrap
A word document embedded in a worksheet won't automatically wrap, the text runs out of the box. This same spreadsheet worked fine in Office 97, won't work right in Office 2003 Pro. It's driving me nuts, this is the specifications pages in my construction estimating spreadsheet, and if I can't use a word document I'll lose access to all my painstakingly written auto text accumulated over the years. I've tried adjusting margins both of the individual worksheet and the word document, but nothing seems to work. ...

View posted information on a folder
how do I access a posted file. I posted a note to a folder and can't find it. Not sure what folder I posted it to. Can I do a search for it? How do I know a folder has a posted note? ...

Upening EXCEL and Word Documents from OE
OE blocks attached Word and Excel documents---what do I do to get them to be unblocked? -- thanks for your hlep This is an Excel group rather than Outlook Express, but in OE click on Tools | Options | Security tab, and then UNCHECK the option "Do not allow attachments to be saved or opened that could potentially be a virus". Click OK and then you should be able to attach and receive Word and Excel files. Hope this helps. Pete On Apr 16, 6:34=A0pm, tidwell <tidw...@discussions.microsoft.com> wrote: > OE blocks attached Word and Excel documents---what do I do to get the...

Outlook Folder Size Help.
I'm wondering if there's a way to export a summary of Outlook subfolders and their size. I know you can check folder size by going to Properties and clicking on the Folder Size button, but I can't sort by size, nor can I export this to a text file. We have a user that is way over his Exchange mailbox limit, and demands that we give him a breakdown of his folders. Unfortunately, he literally has hundreds of subfolders, so browsing through the small folder size window is not an option. Are there any tools or utilities that will report or export the folder size summary? Thanks. ...

Excel formula fill. Help needed...
Group, I are trying to fill a number of rows from a formula that is based on previously calculated data. For example, column D has values based on Column B where D3 is the sum of D2+B3. I auto filled Column D the desired number of rows and the rows filled in properly. Now, Column E is based on Column D minus a constant of 234 with the same pattern as Column D where E3 is the difference of D3-I4 (the cell with the value 234). Now, how would I fill in Column E the desired number of rows (85). Thanks, Jim =D3-$I$4 "Jim" <Jim_mace@Hotmail.com> wrote in message new...

Excel and WiFi
Hi all, I was already posting about slow starting of Excel, it was starting up over a minute. I discovered that when I turn off my WiFi software from boot, it starts normally. When wireless network is connected it starts normally also. Problem is only when WiFi is not connected, and there is Wifi software loaded at boottime. My question is, what is Excel doing at startup, that needs to check accessibility of wireless network ? Is it a way to turn it off ? Regards Pawel Why hasn't anyone responded to this question? I've also been experiencing the same issue. Everything else...