I'm wrote the following macro which imports data from an excel file into access. The data i'm importing fluctuates however (sometimes A1:B2, sometimes A1:B5 etc...) so what I ideally would want is that it selects all the relevant data. So it should do something like:
- Select cell A1
- XLtoRight
- XLDown
- Copy this in access...
Anybody an idea on how I can achieve this?
Sub ImportExcel()
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWb = ExcelApp.Workbooks.Open("C:\Documents and Settings\aa471714\Desktop\Book1.xls")
ExcelApp.Visible = True
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, "Gegevens", "C:\Documents and Settings\aa471714\Desktop\Book1.xls", True, "A1:B5"
With ExcelApp
.Quit
End With
MsgBox ("De gegevens zijn ingelezen")
End Sub