formulas in code error

  • Thread starter Thread starter Kou Vang
  • Start date Start date
K

Kou Vang

I am trying to write a macro and came across this error

range("d2").formula = "=text(c2,"yyyy")"

It keeps saying that the end statement for the "yyyy" is
wrong? I don't know if it is because of all the "s or
what? How do I get around this problem of inserting
formulas in the code itself? Thanks.
 
Hi Kou,

Use double double quotes. As in:

Range("d2").Formula = "=text(c2,""yyyy"")"

HTH

Peter Beach
 

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

Back
Top