Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2001
    Location
    SF, CA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert Simple "If" formula (2000--VBA)

    Hi,

    I'm trying to insert a formula into a cell via VBA.

    range("d2").Formula = "=IF(C2="cd",B2*0.66,B2)"

    But I get this error message: Compile Error! Expected End of Statement.

    What's wrong?

    Thanks!

  2. #2
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Silicon Valley, California, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert Simple "If" formula (2000--VBA)

    Just double-up on the double quotes within the formula portion, so that the VB editor knows you want a quote in the formula, instead of ending the line prematurely, like so:

    <pre>Range("d2").Formula = "=IF(C2=""cd"",B2*0.66,B2)"
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •