Solved

Create and Name a folder from .xls file

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
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…

707 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