I am trying to use the INSERT INTO command to write data into an Access 2007 file from a excel 2010 file. The data is contained in the "NewProj" worksheet in the Tool_Selector.xlsm excel file and it needs to be written to the "Tool_Database.mdb" file but unfortunately I have received several different errors.. This is what I currently have
Sub AddData()
Dim Cn As ADODB.Connection
Set Cn = New ADODB.Connection
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Tools_Dev\_Tool_Selector\Tool_Selector.xlsm;Extended Properties=Excel 8.0;" _
& "Persist Security Info=False"
Cn.Execute "INSERT INTO Project_Names IN 'D:\Tool_Database\Tool_Database.mdb' SELECT * FROM Worksheets("NewProj").Range("A2").Value"
Cn.Close
Set Cn = Nothing
End Sub
I got the code from this thread: Insert Data from Excel into Access using VBA
I just need to transfer the value of individual cells.
Thanks.
?worksheets("newproj").[a1]I do not think you can refer to a worksheet by name as you have done. If that works, you can use that in oace of the existing reference, without the question mark, of course. BTW in Stackoverflow, if you prefix a person's name with @, they will get a message, otherwise they may miss it, unless they are the author of the post.