Solved

Create folders and subfolders from cell entries

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
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 Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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