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. |
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. |
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. |
All times are GMT +1. The time now is 07:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com