I'm trying to run a module in Access 2003 that takes an excel file, if there is info in the cell, then copy the field header and cell in A1, B1, etc... as it loops through each row. There are also comments in the cells with data that need to be copied.
So in a perfect scenario the code would go through each row, cell by cell, and grab the user, the date, the cell's data and the comment and create a new record in an already existing access table. If the cell is empty then it will be bypassed. I have 4 sheets and I know how to make code loop, I just can't get access to pull from excel at all.
I don't want to just import data either, it needs to be sorted with comments in tact.
Any advice would be greatly appreciated. Thanks!
Below is the closest I think I've gotten btw:
Sub copy3()
Dim rs2 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection
Dim cmd2 As New ADODB.Command
With cnn2
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\FilePath.xls;" & "Extended Properties=Excel 8.0;"
.Open
End With
Set cmd2.ActiveConnection = cnn2
cmd2.CommandType = adCmdText
cmd2.CommandText = "SELECT * FROM [Jan-Mar$] Where [Name] IS NOT NULL"
rs2.Open cmd2
While Not rs2.EOF
...Not sure what to write here but I got a msgbox to appear...
rs2.MoveNext
Wend