Solved

Create and Name a folder from .xls file

Posted on 2013-02-04
5
185 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

837 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