+ Reply to Thread
Results 1 to 9 of 9

How to fix my code to make a folders and subfolders?

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    How to fix my code to make a folders and subfolders?

    Hi!

    I am trying to code of making a folders and sub-folders from an Excel.

    Yet I could not figure out how to come up with the result as illustrated below

    RESULT:

    Folder Sub-folders

    6. June 6-Jun_Morning
    6-Jun_Lunch
    6-Jun_Evening

    I have the code below, it works somehow but only the sub-folders 6-Jun_Morning are populated inside the Folder 6.Jun
    the others are outside from Folder 6. Jun.

    Sub createfolders()
    Dim fpath As String
    Dim i, xc As Integer

    On Error Resume Next

    For i = 1 To ActiveSheet.UsedRange.Rows.Count
    xc = Range("XFD" & i).End(xlToLeft).Column

    If xc = 1 Then
    fpath = Cells(i, xc).Value

    Else
    fpath = Cells(Cells(i, xc).End(xlUp).Row, xc - 1).Value & "/" & Cells(i, xc).Value

    End If
    MkDir ("C:\Users\HP\Desktop\TP MASTER\Back Up\" & fpath)

    If Error.Number <> 0 Then
    Err.Clear

    End If
    Next

    End Sub

    ------

    I have attached my Excel for a reference.

    Please any help is really appreciated.

    Regards,
    Rev12
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to fix my code to make a folders and subfolders?

    Start with this

    change
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: How to fix my code to make a folders and subfolders?

    Thanks for any help, yet I could not get to the result I want.

    That my Folder should have a sub folders as below

    Folder Sub Folders
    6.Jun 6_Jun-Morning
    6_Jun-Lunch
    6_Jun-Evening

    Any help please.

    Thanks in advance,
    Rev12

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to fix my code to make a folders and subfolders?

    Try

    Please Login or Register  to view this content.
    Kind regards
    Leo

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: How to fix my code to make a folders and subfolders?

    Quote Originally Posted by LeoTaxi View Post
    Try

    Please Login or Register  to view this content.
    Kind regards
    Leo



    Yes thanks it works will but a little change I need another folders where my sub-folders should be save then as below


    Main Folder Main Sub Folder sub Folders

    6.June 6_Jun-2018 6_Jun-Morning
    6_Jun-Lunch
    6_Jun-Evening

    How do I modify the code?

    thanks again,
    Rev12

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to fix my code to make a folders and subfolders?

    compris pas



    Cordialement
    Leo

  7. #7
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: How to fix my code to make a folders and subfolders?

    is there another way to modify the code because I made only a minor changes??


    Main Folder Main Sub Folder sub Folders

    6.June 6_Jun-2018 6_Jun-Morning
    6_Jun-Lunch
    6_Jun-Evening


    thanks again,
    Rev12

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to fix my code to make a folders and subfolders?

    You can make any dir with this

    Please Login or Register  to view this content.
    just see all necessary is in mypath

    Kind regards
    Leo

  9. #9
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: How to fix my code to make a folders and subfolders?

    Thanks anyways, appreciated.

+ 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. VBA code to loop through folders and subfolders under date time conditions ?
    By hopeful_positive in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2018, 11:45 AM
  2. Loop through folders and subfolders - Tweaking existing code
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-29-2016, 09:20 AM
  3. Create folders in all the subfolders and move subfolders
    By Amarjeet Singh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2015, 12:51 PM
  4. How to make this code search subfolders??
    By windowshopr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2014, 10:39 AM
  5. Macro Code to Encrypt Multiple Excel Files in Folders and Subfolders
    By ali_1989 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2014, 12:53 PM
  6. [SOLVED] VBA code to add folders and subfolders
    By rhlittau in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2013, 06:57 PM
  7. [SOLVED] Creating Folders and Subfolders
    By matt1133 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2013, 03:52 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