pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
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
http://www.vbaexpress.com/kb/getarticle.php?kb_id=1042
also please check this link
http://www.automateexcel.com/2008/09/13/vba-list-of-all-files-contained-within-a-directory/
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
Thanks everyone for helping.
Pedie.
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
http://www.vbaexpress.com/kb/getarticle.php?kb_id=1042
also please check this link
http://www.automateexcel.com/2008/09/13/vba-list-of-all-files-contained-within-a-directory/
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
Thanks everyone for helping.
Pedie.