View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_477_] Leith Ross[_477_] is offline
external usenet poster
 
Posts: 1
Default Opening Workbooks / Filling Array


Hello Bill,

This macro will create a variant array of all files in the director
you choose and of the type you specify.

Your macro would look like this...
Sub MyMacro()
Dim Files
Files = GetFileList("\\sphere\Obit\", "xls")
For I = 1 To Files(0) 'The zero element holds the File count
Workbooks(Files(I)).Open
Next I
TrackerArray = Files()
End Sub

Get Files Macro Code:

Public Function GetFileList(ByVal File_Directory As String, ByVa
File_Type As String) As Variant

Dim FileCount As Long
Dim FileList() As String
Dim FileName As String

FileName = Dir(File_Directory & "\*." & File_Type)
ReDim FileList(0)

Do While FileName < ""
FileCount = FileCount + 1
ReDim Preserve FileList(FileCount)
FileList(FileCount) = FileName
FileName = Dir
Loop

FileList(0) = FileCount

GetFileList = FileList()

End Function

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=50304