ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple Selects (https://www.excelbanter.com/excel-programming/329610-multiple-selects.html)

phil

Multiple Selects
 
Hi All,

This is probably a easy question to answer and I have tried a few things but
with no luck. I am using a connection to a database to get some data out of
it and display it in Excel, the code looks some thing like :-

Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=XXX;UID=XXX;pword=XXXAPP=Microsoft®
Query;WSID=XXX;DATABASE=XXXX;Network=DBMSSOCN;Trus ted_Connection=Yes" _
, Destination:=Range("A1"))
.CommandText = Array("select * from TABLE")
Debug.Print .CommandText
.Name = "Sheet1"

This code just places the return results in Sheet1 starting from Cell's A1,
what I would like to do is in the same module call a second select statement
and place the results in the same sheet but starting from D1, I have tried a
few things but I can only get the first select's worth of data to show and
nothing else.

If anyone could help that would be great.

Thanks

Phil

Andibevan[_2_]

Multiple Selects
 
Hi Phil,

I may be missing something but would you merely need to change
Destination:=Range("A1")) to Destination:=Range("D1"))?

Andi

"Phil" wrote in message
...
Hi All,

This is probably a easy question to answer and I have tried a few things but
with no luck. I am using a connection to a database to get some data out of
it and display it in Excel, the code looks some thing like :-

Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=XXX;UID=XXX;pword=XXXAPP=Microsoft®
Query;WSID=XXX;DATABASE=XXXX;Network=DBMSSOCN;Trus ted_Connection=Yes" _
, Destination:=Range("A1"))
.CommandText = Array("select * from TABLE")
Debug.Print .CommandText
.Name = "Sheet1"

This code just places the return results in Sheet1 starting from Cell's A1,
what I would like to do is in the same module call a second select statement
and place the results in the same sheet but starting from D1, I have tried a
few things but I can only get the first select's worth of data to show and
nothing else.

If anyone could help that would be great.

Thanks

Phil



phil

Multiple Selects
 
Hi Andi

Thanks for the reply, what I mean is I want to run both of the select
statments from the same macro, so that I have the data from select (1) in
column A1 and the data from the select (2) in D1, sorry I should of explained
better, my fault.

Thanks again, Philip

"Andibevan" wrote:

Hi Phil,

I may be missing something but would you merely need to change
Destination:=Range("A1")) to Destination:=Range("D1"))?

Andi

"Phil" wrote in message
...
Hi All,

This is probably a easy question to answer and I have tried a few things but
with no luck. I am using a connection to a database to get some data out of
it and display it in Excel, the code looks some thing like :-

Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=XXX;UID=XXX;pword=XXXAPP=Microsoft®
Query;WSID=XXX;DATABASE=XXXX;Network=DBMSSOCN;Trus ted_Connection=Yes" _
, Destination:=Range("A1"))
.CommandText = Array("select * from TABLE")
Debug.Print .CommandText
.Name = "Sheet1"

This code just places the return results in Sheet1 starting from Cell's A1,
what I would like to do is in the same module call a second select statement
and place the results in the same sheet but starting from D1, I have tried a
few things but I can only get the first select's worth of data to show and
nothing else.

If anyone could help that would be great.

Thanks

Phil





All times are GMT +1. The time now is 11:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com