I would like to pull 10 random records from Excel and create a new spreadsheet. This is what I have so far. I would really like to do this all through ADO instead of creating an instance of Excel and pasting the data into it. Any suggestions?
Swi
Code:
Option Explicit
Dim conn, rs
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = 1
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.RecordSet")
conn.CursorLocation = adUseServer
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test.xls;" & _
"Extended Properties=""Excel 8.0;"""
rs.Open "SELECT TOP 10 * FROM [ZIP4] ORDER BY RND([ZIP4])", conn, adOpenStatic, adLockReadOnly, adCmdText
Swi