1

(This is an updated version of this question - I am trying my best to make myself clearer this time.)

I am trying to use a query to copy values from one column to another.

Both source and destination columns have a name on their left columns, and the name must match. The source names could be duplicated, and in that case, I would like to have the entry on the bottom. There could be empty rows as well.

If a name in the source is not found in the destination, then don't copy it.

If a name in the destination is not found in the source, then leave the destination value blank.

Please see the picture. demo picture

1

Please use
(Do adjust ranges to your needs)

=ArrayFormula(IFERROR(VLOOKUP(G2:G, 
                QUERY(SORTN(SORT({ROW(D2:D),D2:E},1,0),9^9,2,2,1), 
                    " select Col2, Col3 where Col2<>'' "),2,0)))

enter image description here

How the formula works

We create a virtual column based on each row, sort and query the result.
We then use the VLOOKUP function to search the values from column G in the range of the query results with the help of the Arrayformula

Functions used:

1
  • It works like a charm. Thanks a lot.
    – sofname
    Feb 25 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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