LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Macro to Pull Data from Seperate Workbooks

Dave, the following will do as requested.

You may need to tweek the dir function or consider just a loop if you have a
fixed file name structure (ie week01.xls, week02.xls....).

Option Explicit

Sub getdata()
' directory where the data is with the trailing \
Const cszDir As String = "C:\data\"
' prefix for the file name
Const cszFilePrefix As String = "file"
' extension for the file name
Const cszFileExtension As String = ".xls"

Dim wsd As Worksheet
Dim wbc As Workbook
Dim lRowDst As Long
Dim szFileCur As String
Dim szDir As String

Set wsd = ActiveSheet
lRowDst = 2
szFileCur = Dir(cszDir & cszFilePrefix & _
"*" & cszFileExtension)
Do While szFileCur < ""
Set wbc = Workbooks.Open(szFileCur, , True)
'get data'
wsd.Cells(lRowDst, 1) = wbc.Worksheets(1).Range("A1")
wsd.Cells(lRowDst, 2) = wbc.Worksheets(1).Range("C1")
wsd.Cells(lRowDst, 3) = wbc.Worksheets(1).Range("D1")
'....
wbc.Close False
szFileCur = Dir
lRowDst = lRowDst + 1
Loop
End Sub

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Dave" wrote:

I need to find a solution to the folowing problem:

There is a network folder with an Exel workbook for every week in the year.
Each Friday it is updated with one new sheet for that week. All the data
contained is in the same format. I need to create a single file that when
one presses a button, will go through all of the workbooks in the network
drive and pull specific information and populate it into the one file. Is
this possible? Any help would be appreciated.

 
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
Need to pull data from the same cell in multiple workbooks. Gluefoot Excel Discussion (Misc queries) 4 October 22nd 09 02:51 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
macro to move and save all sheets to seperate workbooks Todd Excel Programming 1 September 15th 06 12:16 AM
How can I pull data from multiple user workbooks into one? Stuart Peters Excel Discussion (Misc queries) 4 April 8th 06 11:29 AM
Data from closed workbooks (pull func, indirect.ext, etc ....) [email protected] Excel Worksheet Functions 1 June 22nd 05 03:24 PM


All times are GMT +1. The time now is 01:52 PM.

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

About Us

"It's about Microsoft Excel"