ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formulas in code error (https://www.excelbanter.com/excel-programming/303878-formulas-code-error.html)

Kou Vang

formulas in code error
 
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.

keepITcool

formulas in code error
 
if you want to assign a quoted argument
you'll have to use double qoutes in vba..

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


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Kou Vang" wrote:

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.



Frank Kabel

formulas in code error
 
Hi
make this
range("d2").formula = "=text(c2,""yyyy"")"

--
Regards
Frank Kabel
Frankfurt, Germany


Kou Vang wrote:
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.


Peter Beach

formulas in code error
 
Hi Kou,

Use double double quotes. As in:

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

HTH

Peter Beach

"Kou Vang" wrote in message
...
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.





All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com