+ Reply to Thread
Results 1 to 7 of 7

How to generate a folder based on cell value

  1. #1
    Forum Contributor
    Join Date
    11-15-2011
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    163

    How to generate a folder based on cell value

    Hi All,

    I am trying to create a new folder within a directory based on the value within a cell however I cant figure out how to change the folder path once the cell value changes.

    I am using the MkDir function to create the folder.

    If I have 3 main folders: C:\Sound Testing C:\Air Testing C:\Environmental

    If I select Sound Testing from my drop down list and enter the test details for Test No.X I then want to create a folder C:\Sound Testing\TestX

    I guess its some sort of 'IF' statement which returns the filepath but not sure how to implement it.

    Any help appreciated

  2. #2
    Registered User
    Join Date
    04-09-2012
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: How to generate a folder based on cell value

    rtcwlomax,

    Assuming:
    1 - The Testing Name on Cell A1
    2 - The Test Number on Cell B1
    3 - The Name Of The File on Cell C1

    Try This:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-15-2011
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    163

    Re: How to generate a folder based on cell value

    Pulsus,

    Thanks very much for your code. It works well and I can adapt if for other uses. The only thing is it seems to come up with a debug error if the folder already exists. Is there any way I can create a message box to say 'The folder already exists. Do you want to overwrite this folder? Y/N'

  4. #4
    Registered User
    Join Date
    04-09-2012
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: How to generate a folder based on cell value

    rtcwlomax,

    Just insert this line before the If:

    Please Login or Register  to view this content.
    And this one after the End If:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-15-2011
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    163

    Re: How to generate a folder based on cell value

    Hi Pulsus,

    Thanks again for your input

    Using Application.DisplayAlerts I get a 'Run-time error: 75 - Path/File Access Error' if the folder already exists

    I used 'On Error Resume Next' to get around this but was more hoping a do a search first to see if the folder existed and then ask user if they wanted to overwrite the folder. Y/N?

    Ive tried to search for a solution but one of the main excel help sites seem to be down today so Im a bit stuck. Thanks again for any help on this.

  6. #6
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: How to generate a folder based on cell value

    To check if a foder exists
    Try the Function FolderExists @
    http://allenbrowne.com/func-11.html


    To create subdirectories see
    http://www.jpsoftwaretech.com/creati...-doesnt-exist/
    regards

    johnjohns

    When you are not sure where to go, every road takes you there!

  7. #7
    Forum Contributor
    Join Date
    11-15-2011
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    163

    Re: How to generate a folder based on cell value

    Hi All,

    Thanks for the replies above.

    Post edited as I worked out solution. Will post code for others to use once I clean it up.
    Last edited by rtcwlomax; 06-11-2012 at 03:57 AM. Reason: Solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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