This reads your data into an array
[VBA]Public Sub GetData()
Dim oConn As Object 'ADODB.Connection
Dim oRS As Object 'ADODB.Recordset
Dim sFilename As String
Dim sConnect As String
Dim sSQL As String
Dim ary As Variant
sFilename = "D:\Book.xls"
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilename & ";" & _
"Extended Properties=Excel 8.0;"
Set oRS = CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM [Sheet1$]"
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If Not oRS.EOF Then
ary = oRS.getrows
Else
MsgBox "No records returned.", vbCritical
End If
oRS.Close
Set oRS = Nothing
Set oConn = Nothing
End Sub[/VBA]





Reply With Quote