Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I use the code below to open workbooks and fill and array. Unfortunately the
workbook names change. I have 50 workbooks that I extract data from. Can someone please assist me in adjusting the code so that is opens the books regardless of the names and then fills the array regardless of the name. ' Opens the Tracker workbooks for each unit Dim strPath As String strPath = "\\sphere\Obit\" Workbooks.Open strPath & "D40.xls" Workbooks.Open strPath & "DLP.xls" Workbooks.Open strPath & "WS_234.xls" Workbooks.Open strPath & "POD.xls" Workbooks.Open strPath & "POD2.xls" Workbooks.Open strPath & "GLOB34.xls" ' Establishes an array Dim Tracker_Array As Variant Tracker_Array = Array("D40.xls", "DLP.xls", "WS_234.xls", "POD.xls", "POD2.xls", "GLOB34.xls) Thanks for your assistance Bill |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
help with filling in an array formula | Excel Discussion (Misc queries) | |||
Filling an array with data | Excel Worksheet Functions | |||
Filling Formulas Across Workbooks | Excel Discussion (Misc queries) | |||
Opening an filling e-mail from excel | Excel Programming | |||
Opening an filling e-mail from excel | Excel Programming |