PDA

View Full Version : [SOLVED:] Help needed with to input formula with vba



rama4672
01-08-2005, 03:33 PM
i need a bit of help to insert a formula into a worksheet by the use of vba, when i try to do it i get an error, here ie the bit of code i am trying with



Range("aa6").formulaR1C1 = "=IF(E6="agy","",IF(E6="o/t","",IF(COUNT(F6,G6)=2,(H6-F6+(H6<F6))*24-0.75,"")))"
Range("aa6:ac250").FillDown


I get the error on the red text, i get a message box saying compile error,expected end of statment

Thank you for any help

Ian

TonyJollans
01-08-2005, 04:26 PM
Hi Ian,

To include quote characters in a quoted string, you must double them up ..


Range("aa6").formulaR1C1 = "=IF(E6=""agy"","""",IF(E6=""o/t"","""",IF(COUNT(F6,G6)=2,(H6-F6+(H6<F6))*24-0.75,"""")))"
Range("aa6:ac250").FillDown

rama4672
01-08-2005, 04:42 PM
Thanks for that tony.
That works ok, i did have to change the formulaR1C1 section to formula for it to work properly.

I did realise that i had put it in the wrong section, and i tried to delete it and do it again in the right place but could not find out how to delete a post.


Thanks

Ian

TonyJollans
01-08-2005, 05:25 PM
No problem, Ian.

Some fool, sorry, excellent administrator gave me special priveleges here so I can do things ordinary mortals can't.

mdmackillop
01-09-2005, 06:24 AM
Only the great and the good get to hide their mistakes, which is why they are infallible! :yes :yes :yes
MD