This example copies selected records from the Customer recordset in the Nwindex.mdb database to a new worksheet.
To create the Nwindex.mdb database, run the Microsoft Excel example for the CreateDatabase method.
Dim db As Database, rs As Recordset
Dim data As Variant
Set db = Workspaces(0).OpenDatabase(Application _
.DefaultFilePath & "\NWINDEX.MDB")
Set rs = db.OpenRecordset( _
"SELECT CUSTMR_ID, REGION FROM Customer;")
data = rs.GetRows(6)
Set theSheet = Worksheets.Add
For r = 1 To UBound(data, 2) + 1
For c = 1 To 2
theSheet.Cells(r, c).Value = data(c - 1, r - 1)
Next
Next
rs.Close
db.Close