Syntax error while applying a formula in a macro


P

pol

Sorry for reposting this question again.

I am getting an error message ' syntax error' while applying the formula in
a macro. This formula is using to convert the date from a string . But it
will work when I am applying the formula directly in a formula bar

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

With thanks and regards

Polachan

Please help
 
Ad

Advertisements

D

Dave Peterson

You have to double up the double quotes:

myFormula = _
"=IF(LEFT(CELL(""format"",RC[1]),1)=""D""," _
& "RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

'then .formular1c1
activecell.formular1c1 = myformula


Sorry for reposting this question again.

I am getting an error message ' syntax error' while applying the formula in
a macro. This formula is using to convert the date from a string . But it
will work when I am applying the formula directly in a formula bar

myFormula =
"=IF(LEFT(CELL("format",RC[1]),1)="D",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"

With thanks and regards

Polachan

Please help
 
J

Jim Thomlinson

Your quotation marks need to be doubled up to indicate that the string
actually contains quotation marks and that it is not the end of the string...

myFormula =
"=IF(LEFT(CELL(""format"",RC[1]),1)=""D"",RC[1],DATE(LEFT(RC[1],4),MID(RC[1],5,2),RIGHT(RC[1],2)))"
 
Ad

Advertisements

S

Shane Devenshire

Hi,

I have a suggestion for avoiding this problem in the future:

1. enter the formula in the spreadsheet and with your cursor on that cell
2. turn on the macro recorder
3. press F2, Enter
4. turn the recorder off

If this helps, please click the Yes button

Cheers,
Shane Devenshire
 

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