Google Sheets – How to Get Value from Cell with Query and Importrange Functions

google sheetsgoogle-sheets-queryimportrange

A1 cell has 1. And I try use value from this cell through:

=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/xxxxxxxx/edit?usp=sharing"; "Sheet1!A:P");       
     "select * where Col1='"&A1&"'"; -1 )

But I can't use information from A1 cell. I have nothing result.
But, if I change code Col1='"&A1&"' to Col1=1 it works.

=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/xxxxxxxx/edit?usp=sharing"; "Sheet1!A:P");       
         "select * where Col1=1"; -1 )

But I need that query function use value from A1 cell.
How to do this?

Best Answer

In the query we only use single quotes when the value is text like klm

"where Col1=' "&A1&" ' "

With numbers we do NOT use single quotes.
It looks like the value in your A1 cell is the number 1
So your query should be

"where Col1="&A1&" "