Google Sheets – How to Reference Cell Outside Range Using Query Function

formulasgoogle-sheets-query

I'm trying to copy cells B to F to another sheet if the text in cell J contains specific text. As an example case, I'm using the query function as:

=query('Sheet 1'!B1:J,"Select * Where J contains 'Apples'") 

and that works fine, but I don't want all cells B to J to be copied across, just cells B to F.

Best Answer

You mention:

...but I don't want all cells B to J to be copied across, just cells B to F.

=query('Sheet 1'!B1:J,"Select B, C, D, E, F Where J contains 'Apples'")