Solved

Create folders and subfolders from cell entries

Posted on 2013-05-27
2
762 Views
Last Modified: 2013-05-27
Dear Experts:

I wonder whether it is possible to create hundreds of folders/subfolders in Windows XP from cell entries.

I have arranged the folders and subfolders to be created as follows in a worksheet:

A2       B2                 C2       D2         E2
K:        MyFolder       10      10-1       10-11
K:        MyFolder       10      10-2       10-21
K:        MyFolder       10      10-3       10-31
etc.     etc.                 etc.     etc.        etc.

The requirements are as follows:

- The path characteristics for the the main folder and the first subfolder are the same for all rows, i.e. 'K:\MyFolder\'
- After that, i.e 'K:\MyFolder\' the folder names vary. A lot of subfolders already exist, i.e. the macro has to skip the creation of already existing ones, i.e. not overwrite them.

I have attached a sample file for your convenience

Help is much appreciated.

Thank  you very much in advance

Regards, Andreas
Create-Folders-From-Cell-Values.xlsx
0
Comment
Question by:AndreasHermle
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39199617
Sub createfolders()
    Dim rw As Range
    Dim cel As Range
    Dim fpath As String
    Dim fnam As String
    For Each rw In Range("B2:E" & Range("A" & Rows.Count).End(xlUp).Row).Rows
        fpath = rw.Offset(, -1).Cells(1, 1)
        For Each cel In rw.Cells
            fpath = fpath & "\" & cel
            fnam = Dir(fpath, vbDirectory)
            If fnam = "" Then MkDir fpath
        Next cel
    Next rw
End Sub
0
 

Author Closing Comment

by:AndreasHermle
ID: 39199671
ssaqibh:

I am so damned happed to be able to turn to this forum for expert advice.

This will save me hours of creating folders manually. I have been given great solutions on many occassions making my life much easier.

ssaqibh, thank you so much for your great and professional help. You are one of the experts with very concise coding.

Again, great job, well done!

Regards, Andreas
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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.

760 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

22 Experts available now in Live!

Get 1:1 Help Now