Hi.
I am trying to import data from Excel Spreadsheet into an access table.
I don't want to import the whole spreadsheet, only a specific range which is not always static.
The key to finding the start position of the range is to look for the word "Group Name".
The end position would be something like start_position.end(xldown)
The problem I am having is because we are accessing all this through Access VBA, it is not recognising some of the stuff in my code.
Here is my code so far:
Code:
Option Compare Database
Sub FindRange()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Dim wb As Object
Set wb = xlApp.Workbooks.Open("C:\Desktop\Test.xlsx")
Dim rng As Object
Set rng = wb.sheets(1).cells.Find(What:="Group Name")
Dim rng2 As Object
Set rng2 = wb.sheets(1).range(rng.Address).end(xldown) 'IT IS NOT LIKING THIS - HOW DO I OVERCOME THIS PART
Basically, all I am trying to do is open up an excel spreadsheet, determine the range which starts from the keyword "Group Name", goes all the way up to column G and then all the way down to the last used row, and then pass this range as a parameter in my DoCmd.TransferSpreadsheet.