Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default 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" a écrit dans le message de news:
...
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
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
Paired Quote marks in Excel IF statement mjwskier Excel Worksheet Functions 2 August 28th 09 09:14 PM
Writing formula to include quote marks in result Valerie Excel Worksheet Functions 4 February 18th 09 10:01 PM
Unwanted single quote displayed in Formula bar Joe Excel Discussion (Misc queries) 21 May 1st 07 03:29 AM
Quote marks in Formulas passed from VB Script in Excel Graysailor Excel Worksheet Functions 2 September 26th 06 07:29 PM
How to keep quote marks for CSV in excel Matt Excel Discussion (Misc queries) 0 August 1st 06 12:30 AM


All times are GMT +1. The time now is 04:33 PM.

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

About Us

"It's about Microsoft Excel"