+ Reply to Thread
Results 1 to 11 of 11

Code to create Folders and sub folders based on variable cell values

  1. #1
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Code to create Folders and sub folders based on variable cell values

    Hello

    I would like some assistance to be able to check if a folder exists and if not, create that folder and sub folders based on variable cell values

    If cell A1 = Red
    cell A2 = Blue
    cell A3 = Green

    The Folder created would be c:\Red\Blue\Green

    Any assistance is greatly appreciated

    Thanks

    Jeff

  2. #2
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Code to create Folders and sub folders based on variable cell values

    Hi,

    Just try this......not as you wanted just created for some one else....Create Directories.xlsm
    See If it could help you......
    Last edited by LokeshKumar; 05-01-2015 at 02:43 AM.
    Lokesh Kumar
    Stay Hungry.. Stay Foolish..
    _________________________________________________________
    Please Click STAR to Add Reputation if my/someone's answer helped!

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,637

    Re: Code to create Folders and sub folders based on variable cell values

    not sure why you posted that file if its not what the OP asked for....
    it doesnt even have any code as such can not even be adapted to suit the OP


    as you cannot make green until Blue folder exist
    http://www.techonthenet.com/excel/formulas/mkdir.php

    its 3 step process

    Please Login or Register  to view this content.
    Last edited by humdingaling; 05-01-2015 at 03:50 AM. Reason: amended code
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,637

    Re: Code to create Folders and sub folders based on variable cell values

    of course if the values in ranges are not folder compatible this code breaks down

    shorter str version

    Please Login or Register  to view this content.
    Last edited by humdingaling; 05-01-2015 at 03:50 AM. Reason: amended code

  5. #5
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Re: Code to create Folders and sub folders based on variable cell values

    Hi humdingaling


    Thanks for your reply and code

    I have created the path C:\Users\vthang\Downloads however both versions crash at the first Mkdir str line

    Thanks

    Jeff

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,637

    Re: Code to create Folders and sub folders based on variable cell values

    whoops, forgot to change back after testing
    just make first = [str = "C:\"] instead

    thats my username and download section which is why it wouldnt work because that directory wouldnt exist on your system

    ie
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Re: Code to create Folders and sub folders based on variable cell values

    Excellent all working perfectly now

    Thanks for your help

  8. #8
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Re: Code to create Folders and sub folders based on variable cell values

    Hi Again

    Not sure if I should have started a new thread but I would like to take this a step further and now use save as to save this file into the last created folder with the file name being the value in cell B1.

    The last part I can do however i'm not sure how to reference the newly created folders.

    Thanks

    Jeff

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,637

    Re: Code to create Folders and sub folders based on variable cell values

    if you add it in the existing code
    str would be the drive and path as string

    Please Login or Register  to view this content.
    should save the file in the newly created folder
    this is where it will go if
    you use the workbook.save or saveas afterwards

  10. #10
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Re: Code to create Folders and sub folders based on variable cell values

    Once again thank you I got that going all OK.

    I added after

    Please Login or Register  to view this content.
    Thanks

    Jeff

  11. #11
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,637

    Re: Code to create Folders and sub folders based on variable cell values

    sure not a problem

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Create folders and subfolder based on 2 cell values
    By Megatronixs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2015, 03:54 AM
  2. Create folders and save text files to these folders
    By bloomingcarrot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2014, 08:14 PM
  3. [SOLVED] Create folders and Sub folders and Sub-Sub folders from 5 columns with VBA
    By arleutwyler in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2014, 04:16 PM
  4. Create hyperlink to folders based on values in col A
    By Biinge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2012, 03:35 PM
  5. Create folders and move and copy files into that folders
    By vijaybharthi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-31-2010, 04:01 AM

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