+ Reply to Thread
Results 1 to 8 of 8

Button to create folder based on cell values & path

  1. #1
    Registered User
    Join Date
    03-29-2016
    Location
    tennessee, US
    MS-Off Ver
    Windows 7
    Posts
    22

    Button to create folder based on cell values & path

    Hi all, I've been trying to patch a macro together that creates new folders for me, and having a rough time. Any help would be appreciated.

    This is how it would work:

    In cell A1, I have a root directory path specified. (say: c:\documents\Project)
    I'll type in a new folder name in cell A2 (for this example, I'll add: "folder_1").
    Cell A3 has a control button. When I click the button, a new folder is added in the root directory (c:\documents\project\folder_1). Then the button moves over to the next column (B3), where I can add a new folder name in B2... and so forth.

    Thanks in advance for any direction!

  2. #2
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Button to create folder based on cell values & path

    To create folder see code below. I'm not sure on the type of algorithm you need for folder names though.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-29-2016
    Location
    tennessee, US
    MS-Off Ver
    Windows 7
    Posts
    22

    Re: Button to create folder based on cell values & path

    Thanks Graym, I'm just learning and that was actually very helpful.
    Playing around with it, I keep running into a run-time error 1004. It doesn't seem different than anything I've seen on other threads, and not sure why ActiveCell is giving me this problem:

    Sub CreateFolder_4()
    Dim myPath As String
    With ActiveSheet
    MyFolder = .Cells(ActiveCell.Offset(-1, 0).Value)
    End With
    myPath = Application.ActiveWorkbook.Path & "\" & MyFolder
    MkDir myPath
    End Sub

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Button to create folder based on cell values & path

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Button to create folder based on cell values & path

    No problem! Keep it up, its a very useful tool. Try this

    Please Login or Register  to view this content.
    & thanks for the Mkdir in your code. I didn't know this was possible without using the Shell function

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Button to create folder based on cell values & path

    @ graym463

    No need for Application, you only need 1 line of code.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-29-2016
    Location
    tennessee, US
    MS-Off Ver
    Windows 7
    Posts
    22

    Re: Button to create folder based on cell values & path

    That did it - thanks so much for your help!!!

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Button to create folder based on cell values & path

    @ ctalley5

    You're welcome

    @ graym463

    Thanks for the rep

+ 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. Macro to open a file and folder that has date in the path based on a cell value
    By mm671750 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2015, 06:31 PM
  2. copy folder path button.
    By johanoosterwaal in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2014, 08:09 AM
  3. [SOLVED] Create a new Folder using Button VBA with cell value as name
    By RichardJSigKits in forum Excel General
    Replies: 3
    Last Post: 06-30-2014, 11:25 AM
  4. How to create folder path from different cell values and option menu?
    By NatanZ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 03:15 AM
  5. Replies: 1
    Last Post: 01-10-2013, 08:22 AM
  6. [SOLVED] Create a new folder based on a cell name or value and save copy onto that folder
    By Le_Tiago in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-20-2012, 01:33 PM
  7. [SOLVED] Browse button on form for folder path
    By Greshter in forum Excel General
    Replies: 2
    Last Post: 01-12-2006, 06:25 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