Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error in this code [email protected] Excel Worksheet Functions 2 December 5th 06 05:21 AM
Error Code 481 MBlake Excel Discussion (Misc queries) 1 May 11th 05 01:27 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM
Code or formulas, not sure which Candee[_22_] Excel Programming 1 April 28th 04 07:08 PM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"