Display a list of Excel files at a specific location

bruty

Active Member
Joined
Jul 25, 2007
Messages
451
Is there any way in Excel to create a list of all Excel files in a given network address?

ie If cell A1 has the network address 'C:\File List\' I am looking for some code or some other way to list in the cells underneath all the Excel files in that directory.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

wob

Board Regular
Joined
May 21, 2002
Messages
105
This should do what you want.
B3 should have the path. C3 should have .xls
Creates a textfile on your C: drive



Dim SearchPath As String
Dim SearchSuffix As String

SearchPath = Range("B3").Value
SearchSuffix = Range("c3").Value

Set fs = Application.FileSearch
With fs
.LookIn = SearchPath
.SearchSubFolders = True
.FileName = SearchSuffix

If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."

Open "h:\excellist.txt" For Output As #1
For i = 1 To .FoundFiles.Count
Print #1, .FoundFiles(i)
Next i
Close #1
MsgBox "c:\excellist.txt updated"

Else
MsgBox "There were no files found."
End If
End With
'
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,651
Messages
5,832,917
Members
430,175
Latest member
Sheenamarie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top