Extracting specific Cells

Butters

New Member
Joined
Jun 24, 2008
Messages
16
I have about 40 workbooks that are all uniform in structure and size. I want to write a macro that will extract data from certain cells (the same ones in each workbook) from a certain tab (named the same in each workbook) and spit them into a new workbook. Any ideas?

Thanks

Josh
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Josh

This code should do the trick

assumptions the data to be extracted is in a worksheet called "A" and cell A1, is being extracted to a workbook and worksheet called "Results".

you will have to set the file paths of the folder the workbooks are in and the Results workbook.

CODE:


Public Sub GetInfo()

Dim target As Workbook
Dim sCurFile As String
Dim sPath As String
Dim i As Integer
i = 1

Workbooks.Open ("C:\test\Results.xls")
sPath = "C:\Desktop" & "\"
sCurFile = Dir(sPath & "*.xls", vbNormal)
Do While Len(sCurFile) <> 0
i = i + 1
Workbooks.Open sPath & sCurFile, , True
Workbooks("Results").Worksheets("Results").Cells(i, 1).Value = Workbooks _ (sCurFile).Worksheets("A").Cells(1, 1).Value
sCurFile = Dir
DoEvents
Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,207,090
Messages
6,076,519
Members
446,211
Latest member
b306750

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top