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?


2 Answers 2


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.


As a side note if you are just moving data around in the same Spreadsheet you can always use

='sheet1'!B1:G10 *HOLD SHIFT+CNTRL and Hit ENTER

And get this!


This will need room to expand to how ever big your selected range/array is.

To save any formula as an arrayformula just hit Enter while Holding SHIFT+CNTRL

Your Answer

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

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