Data import

G

gerald

I am trying to create a function that extracts data from a
Sql Server into Excel.

My current design which looks something like below, works
O.K using "QueryTables.Add" but problem is that it can
only return to a range on the worksheet, well as i want
result returned to a variable which I can manipulate
further.

Does anyone know of a way of achieving this.

Function xyz

connstring = _
"ODBC;DSN=CSTW2K.SUNDB;UID=sa;PWD="
With ActiveSheet.QueryTables.Add(
Connection:=connstring, _
Destination:=Range("a11"), Sql:=sqlstring)
.RefreshOnFileOpen = False
xlInsertDeleteCells
.Refresh
End With


End Function


N.B I tried using "SQLRequest" which returns an array but
I could not solve problem with "XLOdbc" that it kept
referring to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top