Here you are Gert Jan. I have had to change the filenames and I have used a table name
[vba]
Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
Public Sub GetData()
Dim oConn As Object
Dim oRS As Object
Dim sFilename As String
Dim sConnect As String
Dim sSQL As String
Dim i As Long
sFilename = "C:\Test\SQL Reading Excel.xls"
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilename & ";" & _
"Extended Properties=Excel 8.0;"
sSQL = "SELECT * FROM StateData WHERE Region='South'"
Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If Not oRS.EOF Then
For i = 1 To oRS.fields.Count
ActiveSheet.Cells(1, i).Value = oRS.fields(i - 1).Name
Next i
ActiveSheet.Range("A2").CopyFromRecordset oRS
Else
MsgBox "No records returned.", vbCritical
End If
oRS.Close
Set oRS = Nothing
End Sub
[/vba]