Solved

Create and Name a folder from .xls file

Posted on 2013-02-04
5
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

756 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