View Single Post
  #6   Report Post  
Jamie Collins
 
Posts: n/a
Default


Arvi Laanemets wrote:
And I have another option too -
I'll place both
grouped queries on same sheet, p.e. first one starting from row 2,

and
second one starting p.e. from row 10000 (I have to estimate maximal

possible
number of rows returned by first query jet), set in query properties

that
result tables are inserted without headers, enter manually headers

into row
1, and define a named range p.e. from row 1 to row 20000, which will

be the
source table for final query - this time a simple one with condition

in
WHERE clause to exclude empty rows.


You shouldn't need to create a defined Name. You can query the
worksheet as a table e.g.

SELECT my_col FROM [MySheet$]
WHERE my_col IS NOT NULL;

This queries the UsedRange (but at a much lower level than VBA) so will
pick up all rows on the sheet.

You can also query the sheet without headers if you put HDR=NO in the
connection string e.g.

SELECT F1 AS my_col FROM
[Excel
8.0;HDR=NO;Database=\\MyServer\MyShare\MyBook.xls;].[MySheet$]
WHERE F1 IS NOT NULL;

In lieu of explicit column headers, Jet assigns default names as F1,
F2, F3 etc.

Jamie.

--