ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to read multiple workbooks, collect a few cells from each? (https://www.excelbanter.com/excel-programming/282668-how-read-multiple-workbooks-collect-few-cells-each.html)

ms

how to read multiple workbooks, collect a few cells from each?
 
I get data in the form of 100 to 300 spreadsheets on a CD-ROM.
I only need a few numbers from each spreadsheet, let's say they
are in cells B4 and C7.
I would like a macro to read each workbook in a folder, and put
its B4 into column B and C7 into column C. i.e
B2 = B4 of 1st workbook
C2 = C7 of 1st workbook
B3 = B4 of 2nd workbook
C3 = C7 of 2nd workbook
B4 = B4 of 3rd workbook etc.

I know how to open muliple files in a folder, but not how to
populate a column, incrementing the row each time.
Where might I find a macro to do this?

Tom Ogilvy

how to read multiple workbooks, collect a few cells from each?
 
psuedo code
dim rw as Row
Wkbk as Workbook
rw = 2
for each wkbk in ListofWorkbooks
' assume wkbk holds a reference to one of the
' workbooks which you have opened and this code
' is in the workbook where you want the summary

with Thisworkbook.worksheets("Sheet1")
.Cells(rw,"B").Value = wkbk.worksheets(1). _
Range("B4").value
.Cells(rw,"C").Value = wkbk.worksheets(1). _
Range("C7").value
rw = rw + 1
End With


--
Regards,
Tom Ogilvy

ms wrote in message
...
I get data in the form of 100 to 300 spreadsheets on a CD-ROM.
I only need a few numbers from each spreadsheet, let's say they
are in cells B4 and C7.
I would like a macro to read each workbook in a folder, and put
its B4 into column B and C7 into column C. i.e
B2 = B4 of 1st workbook
C2 = C7 of 1st workbook
B3 = B4 of 2nd workbook
C3 = C7 of 2nd workbook
B4 = B4 of 3rd workbook etc.

I know how to open muliple files in a folder, but not how to
populate a column, incrementing the row each time.
Where might I find a macro to do this?





All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com