Solved

Create and Name a folder from .xls file

Posted on 2013-02-04
5
180 Views
Last Modified: 2013-02-05
I want to create a group of folders based off a excel file.  example:  There is an .xls file with a list of names (sue.smith, joe.blow,  Peter.Johnson)  I would like to create 3 folders with those being the names of the folder.

I suppose it could take a .csv file too...
0
Comment
Question by:und-josh
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
terencino earned 475 total points
ID: 38853678
Hey und-Josh, here is a script to create those folders for you. After adding the macro to your workbook, add a reference to Microsoft Scripting Runtime, select the cell with the folder names you want, then run the CreateFolders macro. It will show a dialog to ask you for a top-level folder where the new folders will be created under.
Hope it helps
...Terry
Sub CreateFolders()
' Add reference to Microsoft Scripting Runtime
Dim c As Range, fso As FileSystemObject, TopLevelFolder, lngCount As Long
Set fso = New FileSystemObject
With Application.FileDialog(msoFileDialogFolderPicker)
  .AllowMultiSelect = False
  .Title = "Select top level folder..."
  .Show
  For lngCount = 1 To .SelectedItems.Count
    TopLevelFolder = .SelectedItems(lngCount)
  Next lngCount
End With

Debug.Print TopLevelFolder
For Each c In Selection
  If c.Value = "" Then GoTo Skip
  fso.CreateFolder TopLevelFolder & "\" & c.Value
Skip:
Next c
End Sub

Open in new window

CreateFolders.xlsm
0
 
LVL 16

Expert Comment

by:terencino
ID: 38853681
In case you have Excel 2003, here is the XLS file. And what was that about CSV?
CreateFolders.xls
0
 
LVL 7

Expert Comment

by:karunamoorthy
ID: 38853691
0
 
LVL 16

Expert Comment

by:terencino
ID: 38853705
I added some code to exit the sub in case you cancelled the dialog box
CreateFolders.xls
0
 

Author Closing Comment

by:und-josh
ID: 38856262
THis is Exactly what I was looking for....thanks for the Macro.  My VB script is a bit rusty.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now