Need to pull data from the same cell in multiple workbooks.

G

Gluefoot

I have a file with about 200 Excel workbooks. Each workbook has 2 sheets. I
need to total up the values from cell "X12" on sheet2 for all 200 workbooks.
Each workbook has a different name. Is it possible to do this in a new excel
sheet?
 
J

joel

Put this macro into a new workbook. Change the FOLDER as required (from
c:\temp)

Sub GetX12()

Folder = "c:\temp\"

Set SumSht = ActiveSheet
RowCount = 1

FName = Dir(Folder & "*.xls")
Do While FName <> ""
Set OldBk = Workbooks.Open(Filename:=Folder & FName)
SumSht.Range("A" & RowCount) = FName
SumSht.Range("B" & RowCount) = OldBk.Sheets("Sheet2").Range("X12")
RowCount = RowCount + 1
OldBk.Close savechanges:=False
FName = Dir()
Loop
End Sub
 
G

Gluefoot

This worked perfectly. And it was my first experience creating a macro. Thank
you so much!
 
H

Help with cell function

maybe you can help me out joel.

joel said:
Put this macro into a new workbook. Change the FOLDER as required (from
c:\temp)

Sub GetX12()

Folder = "c:\temp\"

Set SumSht = ActiveSheet
RowCount = 1

FName = Dir(Folder & "*.xls")
Do While FName <> ""
Set OldBk = Workbooks.Open(Filename:=Folder & FName)
SumSht.Range("A" & RowCount) = FName
SumSht.Range("B" & RowCount) = OldBk.Sheets("Sheet2").Range("X12")
RowCount = RowCount + 1
OldBk.Close savechanges:=False
FName = Dir()
Loop
End Sub
 
Joined
Mar 5, 2010
Messages
1
Reaction score
0
This code works great but.....

This code works great for what I originally needed it for! I tried manipulating the code to allow me to pull many cells from each of the work books; but was lost in how to do that. For instance; I would like to pull a17:j33 from each of the workbooks. All of my attempts have only allowed me to capture 1 row from each of the workbooks. Can someone show how the above code would work with my changes incorporated please.
thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top