Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Using variables in RCs

Hi. I would like to have the following formula contain a variable if
possible. For instance, instead of having "RC[-10]", I would like to have
"RC[-j]" where "j" is a variable. Is there a way to do this?

ActiveCell.FormulaR1C1 =
"=IF((RC[-10]+RC[-4])0,RC[-10]/(RC[-10]+RC[-4]),na())"

Thanks,
Mike.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Using variables in RCs

Try:

"=IF((RC[-" & j & "]+...."

etc.

--

Vasant




"Mike D." wrote in message
...
Hi. I would like to have the following formula contain a variable if
possible. For instance, instead of having "RC[-10]", I would like to have
"RC[-j]" where "j" is a variable. Is there a way to do this?

ActiveCell.FormulaR1C1 =
"=IF((RC[-10]+RC[-4])0,RC[-10]/(RC[-10]+RC[-4]),na())"

Thanks,
Mike.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Using variables in RCs

To make the debugging easier, I usually do it like this:

Dim s As String
j = 10
k = 4

s = "=IF((RC[##]+RC[@@])0,RC[##]/(RC[##]+RC[@@]),na())"
s = Replace(s, "##", Format(-j))
s = Replace(s, "@@", Format(-k))

This way, I find it easier to ensure I have the basic formula correct.

On Tue, 1 Mar 2005 08:37:04 -0800, "Mike D."
wrote:

Hi. I would like to have the following formula contain a variable if
possible. For instance, instead of having "RC[-10]", I would like to have
"RC[-j]" where "j" is a variable. Is there a way to do this?

ActiveCell.FormulaR1C1 =
"=IF((RC[-10]+RC[-4])0,RC[-10]/(RC[-10]+RC[-4]),na())"

Thanks,
Mike.


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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Too Many Variables Heliocracy Excel Worksheet Functions 6 April 6th 07 07:02 PM
Three Variables George Excel Worksheet Functions 1 July 8th 06 07:47 PM
Using variables . . . Wayne Knazek Excel Discussion (Misc queries) 2 July 6th 06 05:01 PM
DIm Variables Todd Huttenstine Excel Programming 4 April 26th 04 04:37 PM


All times are GMT +1. The time now is 01:13 AM.

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"