+ Reply to Thread
Results 1 to 7 of 7

Simple: Create folder based on cell value

Hybrid View

Hooty Simple: Create folder based... 10-25-2012, 02:37 PM
TMS Re: Simple: Create folder... 10-25-2012, 02:44 PM
RHCPgergo Re: Simple: Create folder... 10-25-2012, 03:09 PM
Hooty Re: Simple: Create folder... 10-25-2012, 07:45 PM
RHCPgergo Re: Simple: Create folder... 10-25-2012, 11:32 PM
Hooty Re: Simple: Create folder... 11-07-2012, 11:21 AM
TMS Re: Simple: Create folder... 10-26-2012, 03:19 AM
  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Exclamation Simple: Create folder based on cell value

    I am a self-taught "NOOB" Code is barely understandable, I have searched for the solution and i have found many that will do what i want, but the code i have found has more features than i need and i do not know how to edit. I have a project tracking sheet with links to the folder i am working on. ex: =HYPERLINK("E:\Users\Corp Est\LM Region\PROJECTS\"&D18&+" - "&+C18,"GO TO FOLDER") or E:\Users\Corp Est\LM Region\PROJECTS\PORT NEAL CONCRETE UNIT 4 - LM-IA1144-C. I manually create these folders, but i'd like to have a macro that creates them for me. I'd also like to be able to create 2 sub-folders: "BOL" and "Tonnage"



    I have a cell that adds the value of several cells to create a folder location:
    (column F)

    ="E:\Users\Corp Est\LM Region\PROJECTS\"&D15&+" - "&+C15 or

    E:\Users\Corp Est\LM Region\PROJECTS\PORT NEAL CONCRETE UNIT 4 - LM-IA1144-C


    the folder "E:\Users\Corp Est\LM Region\PROJECTS\" exists, I want to add folders as i add projects to my list
    I want to press a button than will search through column E and create a folder for the values it finds unless
    it already exists.

    Thanks!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,167

    Re: Simple: Create folder based on cell value

    That's not so difficult ...

    Sub Test()
    
    MkDir "C:\Test"
    MkDir "C:\Test\Excel"
    MkDir "C:\Test\Excel\Folder1"
    MkDir "C:\Test\Excel\Folder2"
    
    End Sub

    Obviously, you might want a bit of error checking and stuff in there.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Simple: Create folder based on cell value

    Hi,

    this macro assumes that your folder names are in column F starting from F2 and there are no empty cells in the list. It will ask if you want to make the two sub folders.
    Sub mkDir_from_cell()
    
    Dim CellDir As String, MyMsg
    Dim i As Integer, x
    
    For i = 2 To ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
        CellDir = ActiveSheet.Cells(i, "F").Value
        If Len(Dir("E:\Users\Corp Est\LM Region\PROJECTS\" & CellDir, vbDirectory)) = 0 Then
            mkdir "E:\Users\Corp Est\LM Region\PROJECTS\" & CellDir
            MyMsg = MsgBox("Make 'BOL' and 'Tonnage' folders?", vbYesNo, CellDir)
            If MyMsg = vbYes Then
                mkdir "E:\Users\Corp Est\LM Region\PROJECTS\" & CellDir & "\BOL"
                mkdir "E:\Users\Corp Est\LM Region\PROJECTS\" & CellDir & "\Tonnage"
            End If
        End If
    Next i
    End Sub
    Last edited by RHCPgergo; 10-25-2012 at 03:11 PM. Reason: spelling

  4. #4
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Simple: Create folder based on cell value

    I won't be back to a cpu that i can test on till Tuesday... Have OpenOffice at home will Macro work the same?

    If my column does have blank cells... Can i make it run till it hits a blank cell, then create several buttons for multiple lists, in the same column?


    Thanks Again!!!

  5. #5
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Simple: Create folder based on cell value

    I think it will work with openoffice, not sure though.

    I don't really understand your second sentence. Create what buttons for what lists?

  6. #6
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Simple: Create folder based on cell value

    "this macro assumes that your folder names are in column F starting from F2 and there are no empty cells in the list. It will ask if you want to make the two sub folders."

    If my column does have blank (empty) cells... Can i make it run till it hits a blank cell, then create several buttons for multiple lists, in the same column? ( If empty cells are an issue, can i assign the macro to run using a "button Function" for each set of lists?) SEE Attached
    Attached Files Attached Files

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,167

    Re: Simple: Create folder based on cell value


+ 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