+ Reply to Thread
Results 1 to 10 of 10

Check to see if folders exist and create if not

  1. #1
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Question Check to see if folders exist and create if not

    Hello

    I want to be able to create a folder using a macro but I want to be able to do a few things prior to this:

    1) I need the macro to go into the top level of the folder Specified in the Macro for example C:\test

    2) I then want it to look to see if there is a folder in here and the lookup reference is as per the contents of cell F2 (contains a year) if the folder doesn’t exist then I would like it created and named based on the contents of F2, if it already exists then I want it to move on to the next step.

    3) If the folder does exist I want to step into that folder and then check to see if another folder exists based on the contents of E2, again as before If it exists then step into the folder and if doesn’t then create it as per the contents of E2

    4) Finally I need to see if it has got down to this step if the folder name as per D2 exists and again step into it if it does or if not I would want a folder created and names as per cell D2

    So to summarise

    Look @ location C:\test
    See if folder named 2014 (Contents of cell F2) exists
    If it does step into it, if it doesn’t create it as per Cell F2 and then step into it.
    Now within this next folder check to see if a folder called Daily Stats August (contents off cell E2) exists
    Again if it does step into it, if it doesn’t create it as per Cell E2 and then step into it.
    Now within this next folder check to see if a folder called Daily 19 Aug (contents off cell D2) exists.
    Again if it does step into it, if it doesn’t create it as per Cell D2 and then step into it.

    If possible I would like the end location of the folder to be entered in cell G2 as text format as I will be moving some files into that end location.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Check to see if folders exist and create if not

    Google the FileSystemObject, this will show you what you need to do.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Check to see if folders exist and create if not

    Thankyou for getting back to me, I have looked this up as per your sugestion but to be honest I wouldnt really know how to use this to achieve what I want, I will have a go but I have a feeling its not an easy request.

  4. #4
    Forum Contributor
    Join Date
    06-24-2005
    Location
    excelliot.com
    MS-Off Ver
    2007
    Posts
    325

    Re: Check to see if folders exist and create if not

    hi

    share sample excel file to help further

    cheers!!

  5. #5
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Check to see if folders exist and create if not

    I'll be surprised if FileSystemObject cant help!

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Check to see if folders exist and create if not

    I'll be surprised if FileSystemObject cant help!

  7. #7
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Question Re: Check to see if folders exist and create if not

    Here is the file attached, I already have a code to move the files but wanted to have the whole task automated if possible as some manual intervention is currently required
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28

    Re: Check to see if folders exist and create if not

    Hi dave1983,

    Assuming:
    1) that you have default dir as "C:\Test\"
    2) data is available in cells D2, E2 and F2

    Try this...

    Insert below given code in a module

    Please Login or Register  to view this content.

    Regards,
    xlman

  9. #9
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Check to see if folders exist and create if not

    thats great I will give it a go and update accordingly, I appreciate your time to put this together

  10. #10
    Registered User
    Join Date
    03-13-2010
    Location
    Mumbai, India
    MS-Off Ver
    2007 & 2013
    Posts
    28
    Hi,

    That's good. It has solved your problem.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    Quick method:
    Select Thread Tools-> Mark thread as Solved.

    You may also thank by clicking on the little star at the bottom left.

  11. #11
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Check to see if folders exist and create if not

    This worked perfetly, thanks for your assistance

+ 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 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
  2. Check If Folders in a List Exist
    By fionaby in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2012, 09:32 AM
  3. Macro to check dynamic file path and create if does not exist
    By Matso in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2011, 01:56 AM
  4. Replies: 3
    Last Post: 03-11-2006, 02:50 PM
  5. Replies: 0
    Last Post: 03-10-2006, 05:55 AM

Tags for this Thread

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