Skip has the right approach but syntactically, the answer is:
"=VLOOKUP($P2,QUERY!$A$2:$Q$" & variable & ",17,FALSE)"
but what you have cannot be in a macro as a formula must be entered as a STRING which you do not have....
Rgds, Geoff
Three things are certain. Death, taxes and lost data. DPlank is to blame
Please read FAQ222-2244 before you ask a question