Vlookup in VBA

R

Rob

I'm trying without success to place the following formula into cell C1 via
VBA code, the formula works fine within the spreadsheet:

=VLOOKUP(LEFT(A1,3),myfile.xls!Database,2,FALSE)&" "&A1&" W/E:
"&TEXT(B1,"dd-mmm-yyy")

So far i've got this part to work but the A1 and B1 elements just don't want
to know!

Range("C1").Formula = "=VLOOKUP(LEFT(A1,3),"myfile!Database,2,FALSE)"

Any help will be most welcome. Rob
 
N

Niek Otten

Hi Rob,

Maybe a typo?
--

Kind Regards,

Niek Otten

Microsoft MVP - Excel
Leave out the quote before myfile
 
B

Bob Phillips

Rob,

Is this what you want

Range("C1").Formula =
"=VLOOKUP(LEFT(A1,3),myfile.xls!Database,2,FALSE)&A1&"" W/E: ""&Text(B1,
""dd-mmm-yyy"")"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the 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