September 14, 2006 at 1:22 pm
I've got a fixed number of excel workbooks from which I need to extract data into a fixed number of tables- however, there are varying numbers of worksheets in each workbook. I know to do a foreach on each file (workbook), but I can't seem to create a foreach object in a file. Is there an iterator for worksheets (/tables) in a workbook (object)?
September 15, 2006 at 6:34 am
I'm assuming you have a reference set to the excel library so you can access its types.
so the following would work
Dim MySheet as Excel.Worksheet
Dim MyBook as Excel.Workbook
MyBook:="C:\temp\book1.xls"
For Each MySheet in MyBook.Worksheets
' Do stuff here
Next
This is for Excel 2000.
HTH,
D'Arcy
September 15, 2006 at 7:43 am
I just found this on the MSDN Site. Hope it helps...
http://msdn2.microsoft.com/en-us/library/ms345182.aspx
September 15, 2006 at 8:39 am
both of you are amazing, thanks so much
September 15, 2006 at 9:18 am
We know!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply