+ Reply to Thread
Results 1 to 8 of 8

Foldername

  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    9

    Foldername

    Hi

    I am in need of vb code which can list down the folder names of a prticular directory path. For example I have a folder "z" located at "c:\" with sub folders like "A", "B" etc and each of the subfolder has numerous files. I need a code which can list the folder names for me i.e. A, B etc on a spreadsheet.


    Ajit Singh

  2. #2
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Foldername

    maybe
    Please Login or Register  to view this content.
    Last edited by venkatpvc; 12-14-2013 at 03:06 PM.
    Give Feedback and Click(*)

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Foldername

    Hi ajt0107

    This Code written by Leith Ross will do as you describe
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Foldername

    heres another one which asks for the folder first

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Foldername

    Hello Ajit,

    This version of the macro allows you to choose the depth of subfolders to return. Passing a zero or no argument returns only the folders in the specified directory. Passing 1 will return the subfolders of each folder in the specified directory. A -1 will return all subfolders of subfolders. This uses only native VBA calls and is comtaible will all version of Excel.

    Macro to ListFolders and Optionally Subfolders
    Please Login or Register  to view this content.
    Example of Using the Macro
    Please Login or Register  to view this content.
    P.S. John - Thanks for the credit.
    Last edited by Leith Ross; 12-14-2013 at 06:43 PM. Reason: Corrected error in code
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Foldername

    @Leith

    You're "stuff" always amazes me...Credit where Credit is due.

    I've not tested your new Code...didn't feel a need to...but it's in my toolbox.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Foldername

    @ John,

    Again, thanks. You are one of the few true gentleman remaining today.

    Slainte agus sonas!
    (May you be healthy and happy)

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Foldername

    @ Leith

    Thanks for the kind words...my best to you and your Family.

    Happy Holidays.

+ 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. rename files in a folder with foldername
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2013, 01:36 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