hey guys,
i found the solution by playing around with some stuff i found on Microsoft's site:
Public Sub return_data()
' Declare the QueryTable object
Dim qt As QueryTable
' Set up the SQL Statement
sqlstring = "select * from test"
' Set up the connection string, reference an ODBC connection
' There are several ways to do this
' Leave the name and password blank for NT authentication
connstring = _
"ODBC;Driver={SQL Server};Server=(local);UID=;PWD=;Database=test"
' Now implement the connection, run the query, and add
' the results to the spreadsheet starting at row A1
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstring)
.Refresh
End With
End Sub
works a treat!
ed
Bookmarks