I need of a little help on this code. It is suppose to import a specific cell into a specific column of my table. (eventually i want this to go through several excel files, small steps LOL)
Here is my code (using access 2007 going to 2003 excel files)
Sub ADD()
Dim myRec As DAO.Recordset
Dim xl As Excel.Application
Dim xlsht As Excel.Worksheet
Dim xlWrkBk As Excel.Workbook
Set xl = CreateObject("Excel.Application")
Set xlWrkBk = GetObject("C:\Documents and Settings\*******\Desktop\*******.xls")
Set xlsht = xlWrkBk.Worksheets(1)
Set myRec = CurrentDb.OpenRecordset("Customers", dbOpenDynaset)
myRec.AddNew
myRec.Fields("Customer") = xlwrksht.Cells(11, "G")
'myRec.Fields("Test2") = xlwrksht.Cells(9, "E")
'myRec.Fields("Test3") = xlwrksht.Cells(11, "E")
myRec.Update
End Sub
I keep getting error 424 object required on this line:
myRec.Fields("Customer") = xlwrksht.Cells(11, "G")
Thanks!