Prøv at kikke på dette eksempel. Her indsættes også en ny record:
You can use either the \"Microsoft Excel ODBC Driver\" or the \"OLE DB Provider for Jet\" to read and update an Excel spreadsheet.
Using the Microsoft Excel ODBC Driver:
Dim oConn As ADODB.Connection
Dim oRs As ADODB.Recordset
\' Create and open a new ADO Connection
Set oConn = New ADODB.Connection
oConn.Open \"Driver={Microsoft Excel Driver (*.xls)};\" & _
\"FIL=excel 8.0;\" & _
\"DefaultDir=C:\\Work;\" & _
\"MaxBufferSize=2048;\" & _
\"PageTimeout=5;\" & _
\"DBQ=C:\\Work\\ADOTest.xls;\"
\' Create the Recordset
Set oRs = New ADODB.Recordset
\' Open the Recordset using a Named Ranged
oRs.Open \"Select * from myRange1\", oConn, _
adOpenStatic, adLockBatchOptimistic, adCmdText
\' Open the Recordset using the Sheet Name
\' oRs.Open \"[Sheet1$]\", oConn, _
adOpenStatic, adLockBatchOptimistic, adCmdTable
\' Open the Recordset using the Sheet Name with row and column area
\' oRs.Open \"Select * from `Sheet1$A2:C4`\", oConn, _
adOpenStatic, adLockBatchOptimistic, adCmdText
Using OLE DB Provider for Jet:
Dim oConn As ADODB.Connection
Dim oCmd As ADODB.Command
Dim oRS As ADODB.Recordset
\' Open a connection to the Excel spreadsheet
Set oConn = New ADODB.Connection
oConn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;\" & _
\"Data Source=Expenses.xls;\" & _
\"Extended Properties=\"\"Excel 8.0;HDR=Yes;\"\";\"
\' Create a command object and set its ActiveConnection
Set oCmd = New ADODB.Command
oCmd.ActiveConnection = oConn
\' This SQL statement selects a cell range in the \"Expenses\" worksheet.
\' oCmd.CommandText = \"SELECT * from `Expenses$A2:C4`\"
\' This SQL statement selects a named cell range defined in the workbook.
oCmd.CommandText = \"SELECT * from `Range1`\"
\' Open a recordset containing the worksheet data.
Set oRS = New ADODB.Recordset
oRS.Open oCmd, , adOpenKeyset, adLockOptimistic
Debug.Print oRS.RecordCount
\' Update last row
oRS.MoveLast
oRS(0).Value = -1
oRS.Update
\' Add a new row
oRS.AddNew
oRS(0).Value = 7
oRS(1).Value = 8
oRS(2).Value = 9
oRS.Update
Debug.Print oRS.RecordCount
\' Clean Up
Set oCmd = Nothing
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
Jeg har fundt det her:
http://www.able-consulting.com/ADO_Faq.htm#Q15