Solved

Create folders and subfolders from cell entries

Posted on 2013-05-27
2
810 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
[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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

728 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