Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to loop thru a group of files and get data from each sheet. I
do the looping fine and open each file with out a problem thanks to some example from the forum(THANKS!). I am having a problem when I read the data. I get the data from the current sheet and not from the sheet in the spreadsheet I have opened. The spreadsheet does open but I keep reading the data from the current sheet and not the open spreadsheet. How should I correct this? Thanks for the ideas and support! Tom Sub ADOFromExcelToAccess() ' exports data from the active worksheet to a table in an Access database Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim r As Long Dim basebook As Workbook Dim mybook As Workbook Dim a As Long Dim FNames As String Dim MyPath As String Dim SaveDriveDir As String Dim test As Variant SaveDriveDir = CurDir MyPath = "E:\Excel\test" FNames = Dir("*.xls") Set basebook = ThisWorkbook Do While FNames < "" Set mybook = Workbooks.Open(FNames) With mybook.Worksheets(1) ...............rest of code looping etc.... ...............This works just cant get to the correct sheet. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping | Excel Discussion (Misc queries) | |||
Looping | Excel Programming | |||
Looping | Excel Programming | |||
Need Looping Help | Excel Programming | |||
looping to create multiple files | Excel Programming |