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: 2
Default Trying to import data from many closed excel workbooks into one: Please Help :-)

Hi,

I have been working with this Macro, but I have some issues getting it
to work the way I would like.

I am attempting to do the following:

Creat a master spreadsheet that will collect data from many identical
spreadsheets all contained in one directory. Each spreadsheet in the
directory contains a summary sheet with one row that I need to bring
into the master spreadsheet in one single worksheet.

With this macro I am able to retrieve one cell just fine, but when I
try to specify to get data from A2 through J2 it brings back a total
into one cell in the master. Does anyone know how I can modify this
macro to bring in rows or many cells instead of just one?

Also if thier is a better way to do this I would be greatful for
suggestions.

Thanks in advance.....


Sub Import()
Dim FolderName As String, wbName As String, r As Long, cValue As
Variant
Dim wbList() As String, wbCount As Integer, i As Integer
Dim MyInput As String
MyInput = InputBox("Enter Directory Path To Your TE's I.E. D:\TE")
FolderName = MyInput
' create list of workbooks in foldername
wbCount = 0
wbName = Dir(FolderName & "\" & "*.xls")
While wbName < ""
wbCount = wbCount + 1
ReDim Preserve wbList(1 To wbCount)
wbList(wbCount) = wbName
wbName = Dir
Wend
If wbCount = 0 Then Exit Sub
' get values from each workbook
r = 0
Workbooks.Add
For i = 1 To wbCount
r = r + 1
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "A2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "B2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "C2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "D2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "E2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "F2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "G2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "H2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "I2")
cValue = GetInfoFromClosedFile(FolderName, wbList(i), "Export
Main", "J2")
Cells(r, 1).Formula = wbList(i)
Cells(r, 2).Formula = cValue
Next i
End Sub

Private Function FinishImport(ByVal wbPath As String, _
wbName As String, wsName As String, cellRef As String) As Variant
Dim arg As String
GetInfoFromClosedFile = ""
If Right(wbPath, 1) < "\" Then wbPath = wbPath & "\"
If Dir(wbPath & "\" & wbName) = "" Then Exit Function
arg = "'" & wbPath & "[" & wbName & "]" & _
wsName & "'!" & Range(cellRef).Address(True, True, xlR1C1)
On Error Resume Next
GetInfoFromClosedFile = ExecuteExcel4Macro(arg)
End Function
 
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
Getting Data from Closed Workbooks NPell Excel Worksheet Functions 3 April 2nd 08 10:28 AM
Import data from a closed workbook David T Excel Discussion (Misc queries) 2 September 17th 07 07:24 PM
CAN I IMPORT DATA FROM A CLOSED FILE TO A NEW WORKSHEET Paul Excel Discussion (Misc queries) 1 January 11th 07 02:30 PM
How do I import data from a closed Excel Spreadsheet? Tomcat Excel Discussion (Misc queries) 2 May 30th 06 12:51 PM
SAVING DATA TO CLOSED WORKBOOKS DarnTootn Excel Worksheet Functions 0 May 15th 06 04:21 PM


All times are GMT +1. The time now is 01:09 AM.

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"