0
votes

I have two spreadsheets Documents DocA and DocB

    A               B           C
1    uid                serial_no   ph
2   356307042189331 3123958     912345678900
3   356307046077540 3966305     923451245123
4   356307046092465 3966407     978458784578
5   356307046098678 3970932     971548745125

In DocB

    A               B
1   serial_no      uid
2   3123958
3   3284728
4   3284655

I am trying to get A2 from DocA into B2 in DocB with the following code

=QUERY(ImportRange("[key]","Sheet1!A:C"),"Select Col1, Col2 where Col1='"&A2&"'",1)

I get

uid serial_no

in Cell B2 instead of the value in Cell A2 of DocA

1
It will be helpful, if you can share a sample spreadsheet.Vasim

1 Answers

0
votes

This seems to do what you want.

=(QUERY(IMPORTRANGE("[key]","Sheet1!A2:B"),"SELECT Col1 WHERE Col2 contains" & "'" & A2 & "'"))

Notice That the Sheet1!A2:B starts with A2 instead of A and the 1 at the end (header Row) is not there. The way you had it will bring in the header (uid) on one row and the value on the row below. I also changed = to contains. Also note the change in quotes around A2.