Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Opening Workbooks / Filling Array

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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with filling in an array formula Caitlin Excel Discussion (Misc queries) 5 November 7th 06 08:12 PM
Filling an array with data Dongle Excel Worksheet Functions 2 May 18th 05 06:06 PM
Filling Formulas Across Workbooks BClifft Excel Discussion (Misc queries) 1 April 22nd 05 09:00 PM
Opening an filling e-mail from excel Tom Ogilvy Excel Programming 0 September 8th 03 01:50 PM
Opening an filling e-mail from excel JMay Excel Programming 0 September 8th 03 12:52 PM


All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Š2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"