Google-sheets – Importing only certain rows

google sheetsgoogle-sheets-queryimportrange

I am attempting to create a spreadsheet based off another spreadsheet. I only wish to import certain rows based on the second column of the first spreadsheet. If that column contains certain users Initials I want the rows to appear in the second spreadsheet.

The formula I am using is (I'm omitting the key):

=QUERY(IMPORTRANGE("key","Sheet1!A2:A3000"),"SELECT * WHERE COL2='JB'")

I keep getting this error message:

Invalid query: Column [COLB] does not exist in table.

I have tried using different terminology for the second column – COL2, even the header name of the column. But nothing works. Not sure what I am doing wrong. Any help would be greatly appreciated!

Best Answer

Your task is hopeless because when only importing a single column there is no second column. However querying say Sheet1!A2:B3000 instead will still not work with COL2 because that is case sensitive, just like column b selection does not work in a query in place of B. Maybe try:

=QUERY(IMPORTRANGE("key","Sheet1!A2:B3000"),"SELECT * WHERE Col2='JB'")