Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create folders and subfolders from cell entries

Posted on 2013-05-27
2
Medium Priority
?
829 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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 tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

618 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