+ Reply to Thread
Results 1 to 4 of 4

Create Folder

  1. #1
    Registered User
    Join Date
    03-08-2018
    Location
    Georgia
    MS-Off Ver
    2016
    Posts
    2

    Create Folder

    Hi Forum Members.

    Need help to create a folders and subfolders based on the data on two worksheets.
    I have attached the outline/excel file as well.

    Sheet2:
    Column B \ Cell B4 onwards contains the name of the master folder created under the path given on the sheet1 (below).

    Sheet1:
    Contains default path in cell B1 for creating the master folders from sheet2 data.

    For every master folder, which is created from sheet2 data, i want to create 3 levels of subdirectories under master folder.

    Example

    Sheet2\B5 Value is CCC. Thus, the macro would create the folder "ccc" on desktop.
    In Folder CCC, we will have 11 folders (Level-1-1 through Level-1-11)
    In Folder Level-1-1, we will have folders Level-2-1 & Level-2-2 and so on.....

    ----------------------------------------------------------------------------


    If the folder name already exists, i want to skip doing anything to that folder.

    If possible, the macro would be triggered based on the pushbutton on sheet2.
    The master folder name would the value in the cell that was selected just before pushing the pushbutton.
    -----------------------------------------------------------------------------------------
    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Create Folder

    Welcome to the forum

    After you have tested code, remove the apostrophe on line below to allow folder creation
    Please Login or Register  to view this content.
    Testing
    To test in attached workbook
    - amend the value in cell B2 (sheet1) to the full path to the folder that "CCC" wil be created in
    - select "CCC" in sheet2 and press the button

    Notes
    1. Sheet1 amended to make it easier to write VBA
    - column B must always contain a value, and column C must contain a value whenever cell in column D is not empty
    2. A Collection is used to hold the list of sub folders to be created
    3. MKDIR must create folders in the correct sequence starting at the TOP level
    - Items are placed in Collection in the corrrect sequence to satisfy MKDIR requirements
    (master folder, followed by all Column B, followed by all Column C, followed by all Column D)
    4. Folder list is written to sheet "FoldersCreated"
    5. MKDIR creates the new folder ( remove " ' " to make it work )
    6. Folders that already exist are ignored

    Caveat
    The code does not check for illegal characters
    - be aware that some characters are not allowed in folder names such as
    < (less than) > (greater than) : (colon)" (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? (question mark) * (asterisk)
    - if some folders are not created that may be the reason

    My Results
    The code has been tested - here is what it created for me
    (all the layers may not be showing, but all were present)
    .
    Folders.jpg
    .
    The code

    Place in Standard Module
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 03-09-2018 at 10:40 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    03-08-2018
    Location
    Georgia
    MS-Off Ver
    2016
    Posts
    2

    Re: Create Folder

    This worked perfect. Thank you very much kev_.


  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Create Folder

    Glad to help
    Please mark thread SOLVED (ThreadTools@TopOfThread)







    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create Folder & Check if Folder Exists if Not Create Folder & then Save File
    By Quivolt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2017, 05:31 AM
  2. [SOLVED] Creating a VBA Script to save in a current month's folder (create folder as needed)
    By spittingfire in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2015, 03:08 PM
  3. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  4. Create FOLDER in subfoldesr and move folders with specific names into FOLDER
    By Amarjeet Singh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2015, 09:46 AM
  5. Code to create New Folder (if doesn't exist) and then Save Workbook to folder
    By jenhawley in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-10-2013, 03:09 PM
  6. Replies: 13
    Last Post: 06-04-2012, 02:18 PM
  7. Replies: 6
    Last Post: 08-11-2006, 03:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1