vlookup with a variable

M

Mentos

hello please help. in vba, i have the following statement

ActiveCell.Formula = "=VLOOKUP(" & sRef1 & " & d2,Sheet6!f:i,4,FALSE)"

actually, what i want to do is to encapsulate the variable sRef1 with
inverted commas. e.g. the variable value is A. so my lookup value is "A"&D2

does that make sense?

if so how do i do that?

cheers
 
B

Bob Phillips

ActiveCell.Formula = "=VLOOKUP(""A" & sRef1 & """ & d2,Sheet6!f:i,4,FALSE)"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
M

Mentos

thanks bob. actually the result was slightly diff to what i expected but i
understand your concept. i modified my statement to:

ActiveCell.Formula = "=VLOOKUP(""" & sRef1 & """ & d2,Sheet6!f:i,4,FALSE)"

and this yielded my result

cheers!
 

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