Hi!
I have a SQL database that I connect to through excel to do some analysis and reports, but I'm having trouble when trying to simplify the connection-prosess. I have a code that looks a bit like this in my excel-macro:
With Sheets("Grunndata").ListObjects.Add(SourceType:=0, Source:="ODBC;DSN=storagedb" _
, Destination:=Range("Grunndata!$A$1")).QueryTable
.CommandText = Array( _
"SELECT transfer.id, transfer.delivnr, transfer.pallenr" & Chr(13) & "" & Chr(10) & "FROM DBA.transfer transfer" & Chr(13) & "" & Chr(10) & "WHERE (transfer.delivnr=16365)" )
And what I want to do, is that on refresh, the number at the end (16365) must come from a certain cell. Change the deliverynr in a cell, hit refresh, and the query against the sql database starts with the new deliverynr...
Thanks for any help.
Kjetil
Bookmarks