+ Reply to Thread
Results 1 to 3 of 3

Excel inserts single quote marks into formula

  1. #1
    Max Bialystock
    Guest

    Excel inserts single quote marks into formula

    When I use vba to insert this formula:
    Sub Macro1()
    ActiveCell.FormulaR1C1 = "=IF(F12=0," & Chr(34) & Chr(34) & Chr(34) &
    Chr(34) & ",IF(F12<0.3,0.3-F12," & Chr(34) & Chr(34) & Chr(34) & Chr(34) &
    "))"

    End Sub
    I get this result:
    =IF('F12'=0,"""",IF('F12'<0.3,0.3-'F12',""""))

    How do I stop Excel from inserting the single quotation marks?

    Cheers,
    Max



  2. #2
    Bob Phillips
    Guest

    Re: Excel inserts single quote marks into formula

    You cannot use FormulaR1C1 with an A1 style formula. Try

    ActiveCell.Formula = "=IF(F12=0," & Chr(34) & Chr(34) & Chr(34) & _
    Chr(34) & ",IF(F12<0.3,0.3-F12," & Chr(34) & Chr(34) & Chr(34) & _
    Chr(34) & "))"

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Max Bialystock" <[email protected]> wrote in message
    news:[email protected]...
    > When I use vba to insert this formula:
    > Sub Macro1()
    > ActiveCell.FormulaR1C1 = "=IF(F12=0," & Chr(34) & Chr(34) & Chr(34) &
    > Chr(34) & ",IF(F12<0.3,0.3-F12," & Chr(34) & Chr(34) & Chr(34) & Chr(34) &
    > "))"
    >
    > End Sub
    > I get this result:
    > =IF('F12'=0,"""",IF('F12'<0.3,0.3-'F12',""""))
    >
    > How do I stop Excel from inserting the single quotation marks?
    >
    > Cheers,
    > Max
    >
    >




  3. #3
    Ardus Petus
    Guest

    Re: Excel inserts single quote marks into formula

    FormulaR1C1 expects R1C1 references.

    Enter Activecell.Formula = "=IF(F12=0,"""",IF(F12<0.3,0.3-F12,"""")"

    HTH
    --
    AP

    "Max Bialystock" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > When I use vba to insert this formula:
    > Sub Macro1()
    > ActiveCell.FormulaR1C1 = "=IF(F12=0," & Chr(34) & Chr(34) & Chr(34) &
    > Chr(34) & ",IF(F12<0.3,0.3-F12," & Chr(34) & Chr(34) & Chr(34) & Chr(34) &
    > "))"
    >
    > End Sub
    > I get this result:
    > =IF('F12'=0,"""",IF('F12'<0.3,0.3-'F12',""""))
    >
    > How do I stop Excel from inserting the single quotation marks?
    >
    > Cheers,
    > Max
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1