Consulting

Results 1 to 7 of 7

Thread: Need macro to list folder with name and size in excel. Thanks

  1. #1
    VBAX Newbie pedie's Avatar
    Joined
    Jul 2010
    Posts
    3
    Location

    Question Need macro to list folder with name and size in excel. Thanks

    Hi,

    I'm wanting excel to find list of folders, name and size...
    it does work, i dont know..it is giving error message.
    code source
    vbaexpress kb/getarticle.php?kb id=1042

    also please check this link
    LINK REMOVED (No permission)
    [vba]

    Option Explicit


    Sub GetFileNames()

    Dim xRow As Long
    Dim xDirect$, xFname$, InitialFoldr$

    InitialFoldr$ = "G:\" '<<< Startup folder to begin searching from

    With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = Application.DefaultFilePath & "\"
    .Title = "Please select a folder to list Files from"
    .InitialFileName = InitialFoldr$
    .Show
    If .SelectedItems.Count <> 0 Then
    xDirect$ = .SelectedItems(1) & "\"
    xFname$ = Dir(xDirect$, 7)
    Do While xFname$ <> ""
    ActiveCell.Offset(xRow) = xFname$
    xRow = xRow + 1
    xFname$ = Dir
    Loop
    End If
    End With
    End Sub
    [/vba]
    Thanks everyone for helping.

    Pedie.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Firstly i have deleted all your other messages in other threads which were simply asking how do i post.

    Secondly why is it not working? what is the error it gives? which version of excel are you using?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Cross-Posted:

    http://www.mrexcel.com/forum/showthread.php?p=2387212

    Duplicate:
    http://www.mrexcel.com/forum/showthread.php?t=483566

    Reference to VBAX KB Article:
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=1042

    Reference to Application.FileSearch method:
    http://www.automateexcel.com/2008/09...n-a-directory/


    @Pedie:

    Please see Here

    Please read Mr. Puls' article in the above link. I cannot imagine a kindlier way of advising reference cross-posting; kudos to Ken.

    I believe you mention working in 2007. .FileSearch was ditched in 2007. I would suggest you keep after xenou's suggestion, albeit, I would most likely go late-bound.

    Mark

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Mark thanks for that and the advice to Pedie
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    4
    Location

    Free Excel file to list files in a folder

    Hi,

    You can get a free Excel file that lists files in any selected folder automatically at the website below.

    excelwell-excel-templates.110mb.com

    Hope that helps.

    :o)

  6. #6

  7. #7
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    4
    Location

    nandakumar's link

    I really like that file Nandakumar, but does anyone know how to alter the macro code so it lists the contents of the specified folder AS WELL AS the contents of all its sub folders in the same way? You'd obviously need another column showing the folder name each file is in.

    That would be fantastic.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •