Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a formula in VBA with quoted strings

I have a cell with the following formula in cell F128 (i.e. cells(128,6):

=SUBTOTAL(1,F126:F127)

I'd like to convert this formula to the following
=text(SUBTOTAL(1,F126:F127),"0.00%") & "/" & text(x,"0.00%")

where x is a real number, and so that the contents of cell F128 become something like
2.00% / 2.50%

I can get some, but not all of this to work in VBA. In particular, if I write
cells(128,6).formula = "=text(" & Mid(Trim(Cells(128, 6).Formula), 2) & ", ""0.00%"" )"

the formula in cell F128 becomes
=text(SUBTOTAL(1,F126:F127),"0.00%")

which solves the first part of my problem, but i I extend it to

cells(128,6).formula = "=text(" & Mid(Trim(Cells(128, 6).Formula), 2) & ", ""0.00%"" )" & "" / ""

it chokes and gives me an run-time error 1004 - Application-defined or object-defined error. I'd be very appreciative if someone could point out the flaw in my method, and point me in the right direction.

Sincerely

Thomas Philips
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Creating a formula in VBA with quoted strings

Figured it out by trying out stuff from other posts in this group:


Cells(BottomRow, 6).Formula = "=text(" & Mid(Trim(Cells(BottomRow, 6).Formula), 2) & ", ""0.00%"" )" & " & " & Chr(34) & " / " & Chr(34) & " & text(" & x & ", ""0.00%"" )"

where x is a real number.


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
Sumproduct with double quoted strings avi Excel Programming 1 January 5th 12 12:50 PM
Creating an array of strings John Excel Programming 1 March 1st 09 02:51 AM
Creating strings for legend [email protected] Excel Discussion (Misc queries) 4 April 27th 08 12:59 PM
question about creating variable from 2 strings Gary Keramidas Excel Programming 2 August 21st 07 09:50 PM
Clean up strings before creating a text file quartz[_2_] Excel Programming 9 October 7th 05 06:52 PM


All times are GMT +1. The time now is 09:12 PM.

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

About Us

"It's about Microsoft Excel"