#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Formula

I wish to, through code, add a formula to a cell.

A1 = 6
B1 = 12

C1 must read - 6 of 12

Using the following in C1 gives the desired results - A1 & " of " & B1

However when I try to code this using C1.formula = "=A1 & " of " & B1"
there is a problem because the formula must be a string and this changes the
output.

Can anyone quickly give me a solution.

PWS


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Formula

Paul

on the worksheet: =A1 & " of " & B1

in code: Range("C1").Formula = "=A1 & "" of "" & B1"

Regards

Trevor


"Paul W Smith" wrote in message
...
I wish to, through code, add a formula to a cell.

A1 = 6
B1 = 12

C1 must read - 6 of 12

Using the following in C1 gives the desired results - A1 & " of " & B1

However when I try to code this using C1.formula = "=A1 & " of " & B1"
there is a problem because the formula must be a string and this changes

the
output.

Can anyone quickly give me a solution.

PWS




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Formula

Hi
try
Range("C1").FormulaR1C1 = "=R[0]C2 & "" of "" & R[0]C2"

--
Regards
Frank Kabel
Frankfurt, Germany


Paul W Smith wrote:
I wish to, through code, add a formula to a cell.

A1 = 6
B1 = 12

C1 must read - 6 of 12

Using the following in C1 gives the desired results - A1 & " of "
& B1

However when I try to code this using C1.formula = "=A1 & " of " &
B1" there is a problem because the formula must be a string and this
changes the output.

Can anyone quickly give me a solution.

PWS

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
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


All times are GMT +1. The time now is 02:18 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"