View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Darren[_2_] Darren[_2_] is offline
external usenet poster
 
Posts: 9
Default Creating a formula which references a dynamic cell location

On May 23, 9:18*pm, Ron Rosenfeld wrote:
On Sun, 23 May 2010 03:30:42 -0700 (PDT), Darren
wrote:

I have a routine for which variables "t" & "s" have a value.


I would like Visual Basic to be able to enter a formula into the
active cell so that it equals whatever value may be contained in cells
(t,s) of the worksheet.


I tried:


Activecell.FoumulaR1C1 = "=R[t]C[s]"


but it is not working.


Any ideas would be much appreciated.


In the future, it will be helpful if you always tell us what you mean when you
write "it is not working". *It may not always be obvious to those trying to
help you.

In any event, you probably want one of the following:

ActiveCell.FormulaR1C1 = "=R[" & t & "]C[" & s & "]"

or

ActiveCell.Offset(1, 0).FormulaR1C1 = "=R" & t & "C" & s

depending on whether "t" and "s" are absolute references, or relative to
ActiveCell.
--ron


Thanks Gentleman. That did the trick. Sorry for the vagueries - I'll
be more specific next time.