0

I have data in a sheet called "PASTE HERE" that I want to import into another sheet in the same workbook. I don't want to use IMPORTRANGE because then copying the workbook would necessitate updating all the workbook URLs in the formulas, and the the ranges always exist in the workbook itself.

So far I have this:

=QUERY("PASTE HERE!D1:I","SELECT D,E,F,G,H,I WHERE E is not NULL order by D ASC ",-1)

Which returns the following error:

Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: D

Column D contains an item number, so blank rows should be ignored, and the imported data should come in in numerical ascending item number order.

There is clearly a column D in the "PASTE HERE" sheet, with data in it.

This does work with IMPORTRANGE as below:

=QUERY(IMPORTRANGE("My sheet URL","PASTE HERE!D1:I"),"SELECT Col1,Col2,Col3,Col4,Col5,Col6 WHERE Col2 is not NULL order by Col1 asc ",-1)

Any idea what I'm doing wrong?

1

1 Answer 1

1

The first parameter to query() should be a range of cells or an array rather than a text string. You can fix the formula like this:

=query('PASTE HERE'!D1:I, "select D, E, F, G, H, I where E is not null order by D", 1)

When you want all columns in the range, you can leave out the select clause:

=query('PASTE HERE'!D1:I, "where E is not null order by D", 1)

It makes sense to specify the number of header_rows explicitly when it is known in advance. The formula above assumes that you have 1 header row. If there are no headers, use 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.