View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] aidan.heritage@virgin.net is offline
external usenet poster
 
Posts: 244
Default ***PLease help. Need to Merge directory of files into one file.***

This code gets all matching files from a directory - change my message
box to whatever you need it to do (insert file by the sound of it!)


Sub lookin()



Set fs = Application.FileSearch
Dim newbook, curbook, MyCount, myrange
With fs
.lookin = "c:\temp\usb"
'LookIn should be changed to the location you want to use
..SearchSubFolders = True 'assuming you DO want to search subfolders

.Filename = "*.xls"
'if you are looking for other than DOC files, alter the line above
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) 0 Then
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)

Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub