LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default formula strings containing quotation marks - VBA

Hi,
Is there a simple way of defining a string variable that will be used in VBA
to insert a formula in a cell, the string variable containing sets of
quotation marks?
I am trying to get VBA to enter a formula in a cell at the end of a long
calculation. The formula is referencing a fixed cell with a name (easy),
followed by some text (also easy) followed by a TEXT function referencing a
(variable) cell containing a date value, and formatting this as "DD/MM/YY".
However, I cannot get the text function to work (as I am entering the cell
row as a variable). I have tried various combinations of using double
quotation marks or Chr(34) to enter the quotation marks but either VBA
objects to the string definition or I get a runtime error when inserting the
string as a formula in the destination cell (using FormString =
Range("destination cell").Formula, FormString being the string I have been
trying to define and "StartTime" being a named reference. The runtime error
occurs even with a fairly simple string of the format:
FormString = "=A7" & "&" & ", from " & "&" & "TEXT(StartTime," & Chr(34) &
"DD/MM/YY" & Chr(34) & ")" - or similar expressions (using &"""&... etc), let
alone when I try to exchange the named cell ("StartTime") with some
combination (say "Sheet1!a"&rownumber) in the formula. I know I could use
Index or Offset and get the macro simply to put the index or offset in a
cell, and then use a manually constructed formula in my target cell but I
would much prefer to write the formula in to the target cell as part of the
macro. I could also simply write the result as text to the target cell but
really want it there as a formula.
I had assumed this would be fairly trivial but it has defeated me so far...
Any help would be most appreciated.
Best wishes, Boris.

 
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
When do I use quotation marks in an Excel formula? Deb Excel Worksheet Functions 3 December 4th 09 07:00 PM
Literal quotation marks retained from a formula Chappy Excel Discussion (Misc queries) 3 February 5th 08 04:17 AM
Quotation Marks? LinearChaos Excel Worksheet Functions 2 June 25th 06 10:31 PM
Passing a function from VB with text strings in quotation marks Max Excel Programming 4 January 13th 06 02:01 PM
Use quotation marks in a formula to display a qty in feet and inc. Jose Excel Worksheet Functions 1 May 12th 05 04:18 PM


All times are GMT +1. The time now is 08:04 AM.

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"