How to define table array in Vlookup function using VBA?

M

michaellm

there's one integer variable, j.
I want to use VLookup function here, and the table Array parameter
should be Column j to j+1
But how to write this code in VBA?
Application.VLookUp(Cells(1,1), COLUMNS(j,j+1), 2 FALSE) ???
It report erros like above.
Thanks.
 
W

weavtennis

If you set up a Vlookup function in the spreadsheet...(un-used cell)

and identify a cell to paste the lookup value... (lookup function first
term)

you can use Excel to do the lookup and then just "get" the value from
the function cell...

something like:

Cells(1,1)="MyValue"
Return_value=cells(1,2)

where the lookup value is in cell(1,1) and the lookup formula is in
cell(1,2)...
 
B

Bob Phillips

Try

Application.VLookUp(Cells(1,1), COLUMNS(j).Resize(,2), 2 FALSE)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top